in reply to using require as c like #include?
There are a couple of problems here. my means lexical scoping, which means the my $HoH in hash isn't supposed to be accessible anywhere else. $HoH in hash is a hashref; then the main code expects a hash.
You'd be better off with use, but it's not necessary. Starting hash like this:
package hash; %HoH = ( 'HASH_1' => {
and using this for the main routine would work:
#!/usr/bin/perl -w use strict; use Data::Dumper; require 'hash'; print Dumper($hash::HoH);
or, you could have hash assign directly to the main namespace:
$main::HoH = { 'HASH_1' => { item_a => "abc",
and then
#!/usr/bin/perl -w use strict; use Data::Dumper; require 'hash'; print Dumper($main::HoH);
(These are examples of what is possible, not what's recommended.)
|
|---|