in reply to access to hashes with same name, from different packages with same name

require() doesn't import. You need to use "use" or call import() yourself. See Exporter and use. Also, q() does not strip spaces. you generally want to use qw() anyway, since that allows you to easily specify a list of space-separated "words".

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,

print Dumper(\%my_hash);
will suffice.

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);