Gossamer Forum
Home : General : Perl Programming :

defining and calling subroutines on the fly

Quote Reply
defining and calling subroutines on the fly
HI there,

I'm having a hard time figuring out how to require a file based on a variable passed in, then calling a subroutine within that file.

like this:

require "Links/Scripts/$scriptname.pm";
$output = $Links::Scripts::$scriptname::process($input) or die "Invalid method: $scriptname called.";

You see, I need to be able to add additional script files that are all structured the same, but there individual filenames will all be different. So that way, I can just upload an additional script, and add a variable. Then based on the value of the variable, the calling script will know which script to include and run.

I'm getting stuck with the $output line above. I can't seem to structure it to dynamically run the proper code.

any ideas?

thanks and peace.