ruhroh has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I have been trying to think up a way to access a hash from an external file. I want to be able to read the values and print it out from the external file.
What I mean is if I have a perl file with:
File_a.pl:
my %test_hash = ( a=>1, b=>2);
Then from File_b.pl (the external file) I want to be able to print the values of inside %test_hash.
File_b.pl:
foreach (keys %test_hash){
print "$test_hash{$_}\n";
}
How do I do this without modifying File_a.pl?
EDIT: Updated to fix a typo with the declaration of the hash. Also, there are other variables(including other hashes) defined in File_a.pl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trying to access hash from external perl file
by toolic (Bishop) on Jul 11, 2012 at 16:42 UTC | |
|
Re: Trying to access hash from external perl file
by davido (Cardinal) on Jul 11, 2012 at 17:55 UTC | |
|
Re: Trying to access hash from external perl file
by tobyink (Canon) on Jul 11, 2012 at 16:44 UTC | |
|
Re: Trying to access hash from external perl file
by daxim (Curate) on Jul 11, 2012 at 16:43 UTC | |
|
Re: Trying to access hash from external perl file
by kennethk (Abbot) on Jul 11, 2012 at 16:48 UTC | |
|
Re: Trying to access hash from external perl file
by ruhroh (Initiate) on Jul 11, 2012 at 17:13 UTC | |
by kennethk (Abbot) on Jul 11, 2012 at 19:06 UTC | |
|
Re: Trying to access hash from external perl file
by Anonymous Monk on Jul 11, 2012 at 21:23 UTC |