I am writing a tool that should import several other perl configuration files. Files are not wrapped w / packages and may have similar or conflicting variables / functions. I have no way to change the format of these files, so I have to work on what they are. What I was going to do was import each into a unique namespace, but I did not find a way to do this with do, requireor use. If I do not use dynamic names, just a solid name, I can do it.
Want something like this:
sub sourceTheFile {
my ($namespace, $file) = @_;
package $namespace;
do $file;
1;
return;
}
This does not work because the package command requires a constant for the name. So, I am trying something like this:
sub sourceTheFile {
my ($namespace, $file) = @_;
eval "package $namespace;do $file;1;"
return;
}
, do, main:: , . ,
do. ( , cat $file eval.)
Devel::Symdump, , .
:
my $xyz = "some var";
%all_have_this = ( common=>"stuff" );
, temp , , . , , ? Perl, , .