pointer/alias questionby shoness (Friar)
|on Dec 01, 2010 at 19:41 UTC||Need Help??|
shoness has asked for the wisdom of the Perl Monks concerning the following question:
I build a data structure as I parse a file. The gist of it is in the code below. I am using Perl 5.8.5 if that matters.
I go round and round. Sometimes I read information on one line and that sets the "context" for the data on the lines that immediately follow. When I want to actually store something, I'm left with a number of state variables to index to where I need to put the data. Instead, I hope to use this "context" to just set a pointer into the data structure that I assemble and keep this as one state variable.
I then hope to collect the data into an anonymous array aliased by the hashref pointer.
Everything looks okay at first. My first call to "Dumper" prints what I expect. When I get to the end however, I see that the data was never placed into the main data structure. If I make multiple passes that should "push" to the same array, they don't show up either.
My pointer/alias is not working...
Output looks like this...
Given the data above, the final expected data should look like this...
If you uncomment the commented lines in the __DATA__ section, then I'd expect data like this...
Re: Grouping an array of hashrefs by similar key values was helpful. Searching for "*" is a tricky thing to do!
Your help is always appreciated!
Update: added the "expected results"