Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: Storing data into hashes

by rkrish (Acolyte)
on Dec 31, 2012 at 10:33 UTC ( #1011037=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Storing data into hashes
in thread Storing data into hashes

Hi, I have used print statement inside the while loop to print the content of data and also used Data::Dumper.The output is as follows

data returned is HASH(0x4e9574) data returned is HASH(0x4e9598) data returned is HASH(0x4e958c) data returned is HASH(0x4e961c) data returned is HASH(0x4e95b0) data returned is HASH(0x4e955c) data returned is HASH(0x4e94fc) data returned is HASH(0x4e9568) data returned is HASH(0x4e95e0) data returned is HASH(0x4e96d0) data returned is HASH(0x22d410) data returned is HASH(0x4e94e4) data returned is HASH(0x22d350) data returned is HASH(0x4e9574) data returned is HASH(0x4e9598) data returned is HASH(0x4e958c) contents of hash is $VAR1 = { '' => undef, 'foo' => 'bar' };
The output of query in sql is as follows:
SQL> select seq_nbr,data_record from usage_inq; SEQ_NBR DATA_RECORD ------------------ ----- 200 10 145 10 205 10 450 10 2227 10 2386 10 202 10 204 10 144 10 472 10 1042 10 SEQ_NBR DATA_RECORD ------------------ ----- 1261 10 203 10 504 10 201 10 503 10 16 rows selected. SQL>


Comment on Re^4: Storing data into hashes
Select or Download Code
Re^5: Storing data into hashes
by roboticus (Canon) on Dec 31, 2012 at 10:37 UTC

    But you didn't use Data::Dumper, so we can't see what the hash reference contains. If you used it you might see something like:

    $VAR1={ COLUMN=>'value', COLUMN2=>'value2' }

    So then you could see the names of the keys in your hash. As mentioned previously, you can't just do:

    print "Foo %hash\n";

    and expect to get anything useful from it.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re^5: Storing data into hashes
by cdarke (Prior) on Jan 02, 2013 at 06:23 UTC
    Looks to me that you are printing the hash after the loop, not in the loop. The hash gets recreated for each row, you need to inspect it inside the loop.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1011037]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-11-28 11:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (196 votes), past polls