Nelson Castillo wrote at Tue, 10 Sep 2002 18:32:41 +0200:
> I want to call a sub, and I've been
> using eval. The problem is that I know this
> is not good and there must be a clever way.
> I must confess that I am a C programmer =)
> I've tried to use something like a pointer
> to the functions with no success.
>
> sub f1($){...}
> sub f2($){...}
>
> my $func;
> if(something){
> $func = 'f1';
> }
> else{
> $func = 'f2';
> }
>
> my $ans= eval "$func(3);";
my $func = (something) ? \&f1 : \&f2;
my $ans = $func->(3);
Greetings,
Janek
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]