|Pathologically Eclectic Rubbish Lister|
Non-fixed data in recordby brassmon_k (Sexton)
|on Aug 31, 2001 at 20:50 UTC||Need Help??|
brassmon_k has asked for the
wisdom of the Perl Monks concerning the following question:
I'm stuck fellow monks, Okay this is the first time I've run into non-fixed data. What I mean by that is that the data is in a block structure but certain lines of the data are on different lines most of the time.
Normally I'd use $/ to break down the blocks into paragraphs and print out $line2 or whatever line. However now I can't do that because let's say $line2 was dog but in my data dog could be on line 5 so if I said:
I'd have it printing cat.
So I was wondering how with a data structure as below could you print out the following lines of data without knowing what line they'll be on. I was reading through the camel book and it sounds like I need to make a hash of arrays but the example wasn't what I wanted it prints out the ARRAY value like (0xcf02) some crazy stuff like that. I want it to print out the value I typed into it. Anyway do I have the right idea to make a hash of arrays for the below data in order to print out a line that isn't always in the same location. For example the lines: "interruptionTime", "chargeParty", "disconnectingParty". Lets say those are the 3 lines I wanted to print and in one record block "interruptionTime" could be on line 2 and in the next block line 18. Here is an example of the data:
So any ideas on how I can achieve this, and is my idea headed in the right direction with a hash of arrays?