You don’t need to load the file to a variable first. Just use do directly on the file:
do 'my_file.pl';
and that “executes the contents of the file as a Perl script.”
Update (in reply to Reaped: Re^2: Use variable as a module during runtime. below): If you want to use the variable, then just use eval on it:
eval $f; warn $@ if $@;
But note what the documentation says regarding scope:
The value of the expression (which is itself determined within scalar context) is first parsed, and if there were no errors, executed as a block within the lexical context of the current Perl program. This means, that in particular, any outer lexical variables are visible to it, and any package variable settings or subroutine and format definitions remain afterwards.
Hope that helps,
Athanasius <°(((>< contra mundum
In reply to Re: Use variable as a module during runtime.
by Athanasius
in thread Use variable as a module during runtime.
by yoda54
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |