Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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
@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 );
The function is called with no arguments.
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"; } }

In reply to Dereferencing Mystery by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-20 02:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found