Additionally, you can only have one package-global variable of the same type and the same name in the same package, so the second import will override the first.
use dir_one::my_package qw(%my_hash); BEGIN { # force this to run before the "use" below print "%s\n", Dumper(\%my_hash); } use dir_two::my_package qw(%my_hash); print "%s\n", Dumper(\%my_hash);
update: also, print() doesn't do what you seem to think it does. See print and printf/sprintf. in this case,
will suffice.print Dumper(\%my_hash);
update 2: almut reminded me that since you specified "%my_hash" in @EXPORT (and not @EXPORT_OK) it will get exported automatically, so you don't need to specify it again when importing. You still need to use "use" or call import yourself, though. That would make the final code something like this:
use dir_one::my_package; BEGIN { # force this to run before the "use" below print Dumper(\%my_hash); } use dir_two::my_package; print Dumper(\%my_hash);
In reply to Re: access to hashes with same name, from different packages with same name
by Joost
in thread access to hashes with same name, from different packages with same name
by utku
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |