in reply to Re^2: modules as data files
in thread modules as data files
The command that brings a file into your code is "require". "use" wraps require and adds a little something to it. Now, in my code, Exporter goes ahead and provides a import() method for you, expecting to use the @EXPORT_OK array to find stuff to bring from use'd namespace to the use-r. That's how $data makes it over from test0 to main.BEGIN { require 'Foo.pm'; Foo->import( 'bar', 'baz' ); }
It's a bit harder to read, but you might put that into a subroutine called my_use() and call it that way. (There's a CPAN module that does this for you, but I don't remember its name off the bat.)(my $filename = $pm) =~ s{ :: }{ / }gx; require "${filename}.pm"; $pm->import( '$data' );
* Well, not exactly, but the exact details would only get in the way.
|
|---|