On 11/6/07, Ab <[EMAIL PROTECTED]> wrote: snip > Now, The thing I am trying to achieve is to call abhinav::test::test2 > on the runtime. > ie, I am passing the value 'abhinav::test::test2' in a variable, and > trying to exec in the code below, and this place I am failing. > Can someone help me as to how to achieve this in runtime. snip
The String version of eval is the wrong method to choose. If you want to execute functions at runtime you want a dispatch table. These are commonly implemented in Perl as a hash whose keys are the names of the subroutines you want to be able to call and the values are references to the subroutines. In your case it should look something like this: my %dispatch = ( 'abhinav::test::test1' => \&abhinav::test::test1, 'abhinav::test::test2' => \&abhinav::test::test2, ); my $dyna_sub = 'abhinav::test::test2'; my @arr = ([1, 2], [3, 4], [5, 6], [7, 8]); die "could not find $dyna_sub to dispatch" unless $dispatch{$dyna_sub}; my $arr = $dispatch{$dyna_sub}->(@arr); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/