Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am attempting to read a flat file that describes an array of hash references into a similar DBM hash where it will be modified and stored for another process. When I test this by first printing out the hash_ptr everything works!When I print out hash_ref( with same address) it references nothing?
The flat file has this
Thanks Much!
The flat file has this
The function is called with no arguments.@HASHES = ( \%Data_Directories_fetch, \%DataDirectories_erase, \%Progr +am_fetch, \%Program_erase, \%Configuration_and_Table_Files_erase, \%Configuration_and +_Table_Files_fetch, \%Create_Database, \%Load_Database );
Thanks Much!
sub loadDefaultsToDBM { my $cntr = 0; foreach $element (@HASHES) { print "$cntr --$element "; switch($cntr++) { case 0 { print "Data_Directories_fetch\n"; $TESS_CONFG{"Data_D +irectories_fetch"} = $element; } case 1 { print "Data_Directories_erase\n"; $TESS_CONFG{"Da +ta_Directories_fetch"} = $element; } case 2 { print "Program_fetch\n"; $TESS_CONFG{"Pr +ogram_fetch"} = $element; } case 3 { print "Program_erase\n"; $TESS_CONFG{"Pr +ogram_erase"} = $element; } case 4 { print "Configuration_and_Table_Files_erase\n"; $T +ESS_CONFG{"Configuration_and_Table_Files_erase"} = $element; } case 5 { print "Configuration_and_Table_Files_fetch\n"; $T +ESS_CONFG{"Configuration_and_Table_Files_fetch"} = $element; } case 6 { print "Create_Database\n"; $TESS_CONFG{"Cr +eate_Datebase"} = $element; } case 7 { print "Load_Database\n"; $TESS_CONFG{"Lo +ad_Datebase"} = $element; } } } ### Test it! my $hash_ptr = \%Program_fetch; print "$hash_ptr\n"; while ( ($key, $value) = each %{$hash_ptr} ) { print "$key => $value\n"; } my $hash_ref = $TESS_CONFG{"Program_fetch"}; print "Result: $hash_ +ref\n"; my @keys = keys %$hash_ptr; while ( ($key, $value) = each %{$hash_ref} ) { print "$key => $value\n"; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Dereferencing Mystery
by tirwhan (Abbot) on Jan 07, 2006 at 23:13 UTC | |
by blankdon (Initiate) on Jan 08, 2006 at 05:15 UTC | |
by Anonymous Monk on Jan 08, 2006 at 01:14 UTC | |
by Anonymous Monk on Jan 08, 2006 at 01:27 UTC | |
Re: Dereferencing Mystery
by planetscape (Chancellor) on Jan 08, 2006 at 01:10 UTC | |
Re: Dereferencing Mystery
by graff (Chancellor) on Jan 08, 2006 at 00:39 UTC | |
by Anonymous Monk on Jan 08, 2006 at 01:02 UTC | |
by davidrw (Prior) on Jan 08, 2006 at 01:14 UTC | |
Re: Dereferencing Mystery
by davidrw (Prior) on Jan 08, 2006 at 01:06 UTC | |
by Anonymous Monk on Jan 08, 2006 at 01:30 UTC |
Back to
Seekers of Perl Wisdom