james28909 has asked for the wisdom of the Perl Monks concerning the following question:
This is the script i call My::Package functions from:
use strict; use warnings; use My::Package (keys %My::Package::); # <-----why does this work? open (my $file, '<', shift); print_lines($file); test("hello world\n"); test_2("hello this is dog");
And this is my module I created for testing:
package My::Package; use Exporter qw(import); @EXPORT_OK = (keys %My::Package::); use strict; use warnings; sub print_lines{ my ($input) = shift; while(<$input>){ print; } close($input); } sub test{ my ($input) = shift; print $input; } sub test_2{ my ($input) = shift; print $input; }
Sample input data:
this is a test!!!!
I just want to know if this is safe to export with @EXPORT_OK = (keys %My::Package::); and import with use My::Package (keys %My::Package::);.
EDIT: Also am I right in thinking that the reason this works is because I am calling that specific module with keys %My::Package::. If i am wrong please help me understand... more better :)
|
|---|