in reply to Re^3: perl eval
in thread perl eval

I dont want to call egal from the script itself. The name of the sub is coming through parameter and I just want to evaluate whatever is there in the parameter.

Replies are listed 'Best First'.
Re^5: perl eval
by johngg (Canon) on Jul 05, 2010 at 19:34 UTC
    and I just want to evaluate whatever is there in the parameter

    That might end in tears!

    use strict; use warnings; my $param = shift; eval $param; die $@ if $@;

    Let's see some files.

    $ perl spw848064 'system ls' reallyImportant.data spw848064 $

    You can see what's coming :-)

    $ perl spw848064 'system qw{rm -f reallyImportant.data}' $

    Oops!

    <!--$ perl spw848064 'system ls' spw848064 $

    It might be worth doing a little sanity checking before evaling willy-nilly.

    Cheers,

    JohnGG