in reply to modules as variables

With the caveat that what you're doing looks like it should be handled as configuration data, here's some code that roughly accomplishes what you want.

use warnings; use strict; BEGIN { (my $filename = $ARGV[0]) =~ s!::!/!g; require "$filename.pm"; $ARGV[0]->import() if $ARGV[0]->can('import'); } print read_file($0);

In this case, the intent is to run perl code.pl File::Slurp.

--Solo

--
You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.

Replies are listed 'Best First'.
Re^2: modules as variables
by tcf03 (Deacon) on Jun 28, 2006 at 18:43 UTC
    Yes - its configuration data - but im porting someone else's code over to a new system that I NEED to get up and running as quickly as possible, next step is to actually fix the code.

    Thanks
    Ted
    --
    "That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
      --Ralph Waldo Emerson