Re: Dynamically calling a subroutine

2007-02-13 Thread Ana Saiz García
On 13/02/07, Igor Sutton <[EMAIL PROTECTED]> wrote: Ana, 2007/2/13, Ana Saiz García <[EMAIL PROTECTED]>: > Thank you all for your answers, they have been very helpful :o) > It would be nice if you post the solution you picked. It is useful for another user like you to search in archives :-)

Re: Dynamically calling a subroutine

2007-02-13 Thread Igor Sutton
Ana, 2007/2/13, Ana Saiz García <[EMAIL PROTECTED]>: Thank you all for your answers, they have been very helpful :o) It would be nice if you post the solution you picked. It is useful for another user like you to search in archives :-) -- Igor Sutton Lopes <[EMAIL PROTECTED]> -- To unsubscr

Re: Dynamically calling a subroutine

2007-02-13 Thread Ana Saiz García
Thank you all for your answers, they have been very helpful :o) Regards Ana -- "El más baldío de todos los días es aquél en que no hemos reído" (de Chamfort)

Re: Dynamically calling a subroutine

2007-02-13 Thread Igor Sutton
Erm. Sorry :-) I have done everything and I don't get anything when doing $ perl module-pluggable-sample.pm, would you know why? First of all I made a type there. It is $ perl module-pluggable-sample.pl The code has an error too. New version below: use strict; use warnings; package Applic

Re: Dynamically calling a subroutine

2007-02-13 Thread D. Bolliger
Ana Saiz García am Dienstag, 13. Februar 2007 13:02: > On 12/02/07, D. Bolliger <[EMAIL PROTECTED]> wrote: > > Ana Saiz García am Montag, 12. Februar 2007 22:26: [snipp and following code stripped] > > #!/usr/bin/perl > > > > # don't forget: > > # > > use strict; > > use warnings; > > > > package

Re: Dynamically calling a subroutine

2007-02-13 Thread Ana Saiz García
Hi again and thank you On 13/02/07, Igor Sutton <[EMAIL PROTECTED]> wrote: Hi Ana, > Don't I have to put "use" and the name of packages A and B anywhere on the > main program? I advice you to use Module::Pluggable for that (as I think you're designing a pluggable system or whatever): Yes,

Re: Dynamically calling a subroutine

2007-02-13 Thread Igor Sutton
Hi Ana, Don't I have to put "use" and the name of packages A and B anywhere on the main program? I advice you to use Module::Pluggable for that (as I think you're designing a pluggable system or whatever): $ cat > module-pluggable-sample.pl use strict; use warnings; package Application; use

Re: Dynamically calling a subroutine

2007-02-13 Thread Ana Saiz García
Hi again and thanks for your help On 12/02/07, D. Bolliger <[EMAIL PROTECTED]> wrote: Ana Saiz García am Montag, 12. Februar 2007 22:26: > Hello Hello Ana > First of all, I apologize if this is not the right list to ask my question, > but as I am a perl beginner, I think it is the most suitab

Re: Dynamically calling a subroutine

2007-02-13 Thread Ana Saiz García
On 13/02/07, Igor Sutton <[EMAIL PROTECTED]> wrote: > Thank you for your idea, but I think this doesn't solve my problem, because > what I don't know a priori is the module's name (in your example, M), not > the function's name. package M; sub my_routine { print "my_routine()\n"; } packag

Dynamically calling a subroutine

2007-02-13 Thread Ana Saiz García
On 13/02/07, Chad Perrin <[EMAIL PROTECTED]> wrote: > The specific module that will be used at a given moment is supposed to be > given by a configuration file, that's why the main program doesn't know its > name a priori (but it does know the name of the subroutine, that must be the > same for

Dynamically calling a subroutine

2007-02-13 Thread Ana Saiz García
Hi again On 12/02/07, Igor Sutton Lopes <[EMAIL PROTECTED]> wrote: You can use the UNIVERSAL's can() method. Assuming you have a module called "M"; package M; sub some_function { print "some_function()", "\n"; } package main; my $function_name = "some_function"; if (my $coderef = M->can($f

Re: Dynamically calling a subroutine

2007-02-13 Thread Ana Saiz García
Hello again and thanks for your answers You all have been very kind with your fast answers, and I have read a lot of good ideas. Tomorrow (I must go to bed *right* now ;o)) I will try them in order to find which one best fits my needs. Many thanks again. Regards Ana -- "El más baldío de tod

Re: Dynamically calling a subroutine

2007-02-12 Thread Jeff Pang
One way to diff the same subroutine name in different modules is using full package name. For example,both package APACK and package BPACK have the same subroutine "mytest()",then you can call them independently by: APACK::mytest(); BPACK::mytest(); It wouldn't make the conflict. Maybe I'm und

Re: Dynamically calling a subroutine

2007-02-12 Thread Igor Sutton Lopes
Hi Ana, On 2007/02/12, at 21:26, Ana Saiz García wrote: Hello First of all, I apologize if this is not the right list to ask my question, but as I am a perl beginner, I think it is the most suitable list for me :o) So here goes my question: I have a main program which will call a subrou

Re: Dynamically calling a subroutine

2007-02-12 Thread Mumia W.
On 02/12/2007 03:26 PM, Ana Saiz García wrote: Hello First of all, I apologize if this is not the right list to ask my question, but as I am a perl beginner, I think it is the most suitable list for me :o) So here goes my question: I have a main program which will call a subroutine, say "S"

Re: Dynamically calling a subroutine

2007-02-12 Thread D. Bolliger
Ana Saiz García am Montag, 12. Februar 2007 22:26: > Hello Hello Ana > First of all, I apologize if this is not the right list to ask my question, > but as I am a perl beginner, I think it is the most suitable list for me > :o) > > So here goes my question: > > I have a main program which will ca

Re: Dynamically calling a subroutine

2007-02-12 Thread Chad Perrin
On Mon, Feb 12, 2007 at 10:26:26PM +0100, Ana Saiz García wrote: > Hello > > First of all, I apologize if this is not the right list to ask my question, > but as I am a perl beginner, I think it is the most suitable list for me :o) > > So here goes my question: > > I have a main program which wi

Dynamically calling a subroutine

2007-02-12 Thread Ana Saiz García
Hello First of all, I apologize if this is not the right list to ask my question, but as I am a perl beginner, I think it is the most suitable list for me :o) So here goes my question: I have a main program which will call a subroutine, say "S", belonging to another module. The question is that

RE: Calling a subroutine - strict very strict

2005-05-06 Thread Tielman Koekemoer \(TNE\)
Maybe I should tell you what fixed it: The "param" was a string so enclosed it in single quotes. Thanks! -Original Message- From: Tielman Koekemoer (TNE) [mailto:[EMAIL PROTECTED] Sent: 06 May 2005 02:33 PM To: [EMAIL PROTECTED]; beginners@perl.org Subject: RE: Calling a

RE: Calling a subroutine - strict very strict

2005-05-06 Thread Tielman Koekemoer \(TNE\)
Thanks Prasanna, that fixed it. -Original Message- From: Prasanna Kothari [mailto:[EMAIL PROTECTED] Sent: 06 May 2005 02:26 PM To: beginners@perl.org Cc: Tielman Koekemoer (TNE) Subject: Re: Calling a subroutine - strict very strict what is "param".? If it's a variable, a

Re: Calling a subroutine - strict very strict

2005-05-06 Thread Prasanna Kothari
what is "param".? If it's a variable, and not declared, qualify it using "my or local". Else, if it's a string that you want pass to the function, use single quotes. -Prasanna Tielman Koekemoer (TNE) wrote: Hi All, I apologise for the newbie question straight off - I don't have my Camel book with

Calling a subroutine - strict very strict

2005-05-06 Thread Tielman Koekemoer \(TNE\)
Hi All, I apologise for the newbie question straight off - I don't have my Camel book with me to consult. Why does the following give me an error?: -- #!/usr/bin/perl -w # # A script that gets a list of technologies that have events on Display layer. # use strict; sub q_db

Re: dynamically calling a subroutine

2005-01-18 Thread JupiterHost.Net
Absolut Newbie wrote: I have a program that generates a random number between 1 and 6. based on the outcome I want to run a subroutine that corresponds to the result. i.e if the result is 1 then the program should run sub F1. my question is how can I dynamically call the subroutine. i tried this b

Re: dynamically calling a subroutine

2005-01-18 Thread John W. Krahn
Absolut Newbie wrote: I have a program that generates a random number between 1 and 6. based on the outcome I want to run a subroutine that corresponds to the result. i.e if the result is 1 then the program should run sub F1. my question is how can I dynamically call the subroutine. i tried this bu

Re: dynamically calling a subroutine

2005-01-18 Thread Ron Wingfield
- Original Message - From: Stone To: beginners@perl.org Sent: Tuesday, January 18, 2005 12:20 PM Subject: Re: dynamically calling a subroutine On Tue, 18 Jan 2005 20:05:01 +0200, Absolut Newbie <[EMAIL PROTECTED]> wrote: > $var1(); # this is where i

RE: dynamically calling a subroutine

2005-01-18 Thread Bob Showalter
Absolut Newbie wrote: > I have a program that generates a random number between 1 and 6. > based on the outcome I want to run a subroutine that corresponds to > the result. i.e if the result is 1 then the program should run sub > F1. my question is how can I dynamically call the subroutine. > > i

RE: dynamically calling a subroutine

2005-01-18 Thread Moon, John
I have a program that generates a random number between 1 and 6. based on the outcome I want to run a subroutine that corresponds to the result. i.e if the result is 1 then the program should run sub F1. my question is how can I dynamically call the subroutine. i tried this but obviously it didn't

Re: dynamically calling a subroutine

2005-01-18 Thread Stone
On Tue, 18 Jan 2005 20:05:01 +0200, Absolut Newbie <[EMAIL PROTECTED]> wrote: > $var1(); # this is where it crashes You're looking for the eval command, which will read a string and evaluate the code it contains. ie: eval ( "$var1()" ); On on the other hand, you could do this with if statement

dynamically calling a subroutine

2005-01-18 Thread Absolut Newbie
I have a program that generates a random number between 1 and 6. based on the outcome I want to run a subroutine that corresponds to the result. i.e if the result is 1 then the program should run sub F1. my question is how can I dynamically call the subroutine. i tried this but obviously it didn't

Re: calling a subroutine as an element of a hash table...

2003-02-10 Thread Peter_Farrar
Oops, hit send by mistake. This problem all seems to be about mistakes... Thanks to all who replied. > You have three different hashes in use. Look: I did indeed have 3 hash tables... Duh (Must have been Friday afternoon). The central problem was calling '&{${$date_format{$format}}{now}}()' i

Re: calling a subroutine as an element of a hash table...

2003-02-10 Thread Peter_Farrar
| PM | | || |-+> >--| | | | To: [EMAIL PROTECTED] | | cc: | |

Re: calling a subroutine as an element of a hash table...

2003-02-07 Thread Dave K
Peter, #!/usr/bin/perl -w use strict; my %date_formats = ( ccyymmdd => { now => sub { my @arr = localtime(); print 'Year ', 1900 + $arr[5] . ' Month '. sprintf("%02d",$arr[4] + 1) . ' Day ' . sprintf("%02d",$arr[3]); } } ); & { $date_formats{ccyymmdd}{now} }; Same output as previous

Re: calling a subroutine as an element of a hash table...

2003-02-07 Thread Dave K
Peter I saw Jenda's note and I suggest the code needs simplification. > P.S. you can see where I comment out the ccyymmdd_now function. That > approach works, but is not what I'm shooting for. > > %date_formats = ( > # "ccyymmdd" => {now => \ccyymmdd_now()}, > "ccyymmdd" => {now => s

Re: calling a subroutine as an element of a hash table...

2003-02-07 Thread Rob Dixon
Peter Farrar wrote: > Hi All, > > I swear I've called subroutines this way before, but I can't find any > examples. > In this case, I'm looking to build some time/date functions. > Regardless of what the actual code is supposed to do, the calling of > subroutines as elements of a hash is causing me

Re: calling a subroutine as an element of a hash table...

2003-02-07 Thread Jenda Krynicky
From: "John W. Krahn" <[EMAIL PROTECTED]> > Peter Farrar wrote: > > I swear I've called subroutines this way before, but I can't find > > any examples. In this case, I'm looking to build some time/date > > functions. Regardless of what the actual code is supposed to do, > > the calling of subrouti

Re: calling a subroutine as an element of a hash table...

2003-02-07 Thread John W. Krahn
Peter Farrar wrote: > > Hi All, > > I swear I've called subroutines this way before, but I can't find any > examples. > In this case, I'm looking to build some time/date functions. Regardless of > what the actual code is supposed to do, the calling of subroutines as > elements of a hash is causi

calling a subroutine as an element of a hash table...

2003-02-07 Thread Peter_Farrar
Hi All, I swear I've called subroutines this way before, but I can't find any examples. In this case, I'm looking to build some time/date functions. Regardless of what the actual code is supposed to do, the calling of subroutines as elements of a hash is causing me grief. I am receiving the foll

Re: Calling a subroutine

2001-12-19 Thread Curtis Poe
--- Chris Zampese <[EMAIL PROTECTED]> wrote: > How do I call a subroutine in a cgi script. I thought that it was just > > subroutine_name(); > > but that does not seem to be working for me? > > You guys are great. Thanks for your help (both from answering my questions, and >from ans

Calling a subroutine

2001-12-19 Thread Chris Zampese
How do I call a subroutine in a cgi script. I thought that it was just subroutine_name(); but that does not seem to be working for me? You guys are great. Thanks for your help (both from answering my questions, and from answering other peoples!) Chris