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
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
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
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
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
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
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
- 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
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
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
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
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
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"
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
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
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
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
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
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
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,
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
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
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)
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
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 :-)
25 matches
Mail list logo