Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^5: Array of hashes reference problem

by sapnac (Beadle)
on Jun 22, 2005 at 20:32 UTC ( #469167=note: print w/replies, xml ) Need Help??


in reply to Re^4: Array of hashes reference problem
in thread Array of hashes reference problem

Check this code; The code posted goes in an infinite loop.
#!/usr/bin/perl -w use strict; my @arrayAoH; my $out = "First one: one Second one: second"; my ( $i,$j ); my ($key,$value); my @discovered = split /\n/, $out; $i = 0; # i holds the line number of the input (@discovered) array. $j = 0; # j holds the number of the table row. until ($i > $#discovered){ ($key, $value) = split /:\s*/, $discovered[$i]; $arrayAoH[$j]{$key} = $value; $i++; }
Hope it helps! Good Luck!

Replies are listed 'Best First'.
Re^6: Array of hashes reference problem
by tlemons (Novice) on Jun 22, 2005 at 21:30 UTC
    Thanks very much! It solved my problem. Aside from the infinite loop, your code worked and my didn't. I stared at it, and noticed that the important difference was:

    Your code
    my @arrayAoH;

    My code
    my @arrayAoH = "";

    By initializing the array, I shot myself in the foot. When I removed that "" initialization, my code worked great.

    Thanks VERY much for the help!

    tl

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2020-11-26 07:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?