in reply to Re: How to call subroutines using variables ?
in thread How to call subroutines using variables ?

eval "&$s()";
Oof. Don't do that. It's a lot safer to turn of strict refs instead:
no strict 'refs'; $s->(); use strict;
That should still be treated with care, though. It will run ANY subroutine (even in other packages) that can be reached by name. Using your eval STRING option will run ANY code that happens to be in $s. Like:

$s = "print(); unlink '/etc/passwd'; s";
updated: fixed quoting

Replies are listed 'Best First'.
Re^3: How to call subroutines using variables ?
by Anonymous Monk on Aug 13, 2007 at 20:49 UTC
    what if function $s is defined another perl module. Even though i include the perl module .I get this error Undefined subroutine &main::hello