Perl include file dynamically -
i have doubt in perl , need filename in command line arguments/switches/options , based on need include/require/use file in script. using getopt variable able done. if have used "use strict" in script not it. please on this
i tried follows , working
base.pm:
our $def_name = "me"; main.pl:
my $name = "mathlib.pm"; require $name; print $def_name; when include follwoing lines in main.pl , base.pm,
use strict; use warnings; i getting error,
global symbol "$def_name" requires explicit package name . execution of main.pl aborted due compilation errors.
$def_name hasn't been exported mathlib.pm, it's package variable not global. $mathlib::def_name work, or can use exporter module export namespace of module uses it.
Comments
Post a Comment