Passing subroutine names via ARGV and calling them. How?

I'd like to pass in subroutine name(s) as arguments to the script and call them.
For example,

"perl myprogram subname1 subname5"

my script will get the names from ARGV and call each one.

How to do this?



  • Hi,

    How about something like:-

    foreach (@ARGV) {
    my $command = '&' . $_ . ';';
    eval ($command); #You could put these as 1 line...

    Of course, there are potential security worries in there, so if this is a script used by many, I'd probably want to be validating it somehow.

    Hope this is what you meant/my code is right,


    Count your downloads:
    And host your site:
    Don't say I never give you anything... ;-)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion