in reply to Re^2: Manipulating data structure
in thread Manipulating data structure
As you parse the file one line at a time and come to CMG1=Ja, the string CMG1 is your keyword and Ja is the associated value. If you needed to know that it was in the twelfth position, then you could for example set up a hash-of-hashes data structure such that $hoh->{'CMG1'}{'Ja'} = 12. Or whatever else suits your fancy. My key point was that, with auto-vivification, you can establish such data structures very easily. You refer to an unassigned variable as a hash ... and it is a hash. You execute as an assignment-statement what I wrote just above, and the desired hash-of-hash element simply appears. $hoh->{'CMG1'} exists, and it has a key {'Ja'}, and that key has the value 12. Presto. Arrays work the same way. It’s entirely up to you to determine what structure you want, but very easy to get it.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Manipulating data structure
by SerZKO (Beadle) on Aug 17, 2012 at 11:01 UTC | |
by Cristoforo (Curate) on Aug 17, 2012 at 15:14 UTC | |
by SerZKO (Beadle) on Aug 17, 2012 at 18:40 UTC |