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

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 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 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 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 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

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

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 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 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 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-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-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

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 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 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 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 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 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
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
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 :-)