arunhorne has asked for the wisdom of the Perl Monks concerning the following question:
Hi
I have a text file in the format below:
T1 Line1 T2 Line2 Line3 Line4 T3 Line5 Line6 ER
Basically it is a tagged file and I need to load it into a hash. As you can see it has potentially has more than one line per tag. I want to create a hash that maps each tag (tags are unique) to an array of the lines associated with that tag, i.e.
T2 => (Line2,Line3,Line4)
Tag names are always two letter but may be arbitrary and therefore cannot be hardcoded, however, the file is always terminated by a tag named ER.
Can anyone provide me with the code to translate this text into a hash to my requirements, I just can't seem to handle the multiline case.
Thanks in advance
____________Arun
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: Parsing a Tagged File Format
by merlyn (Sage) on Apr 30, 2003 at 10:38 UTC | |
Re: Parsing a Tagged File Format
by broquaint (Abbot) on Apr 30, 2003 at 10:40 UTC | |
Re: Parsing a Tagged File Format
by Anonymous Monk on Apr 30, 2003 at 10:41 UTC | |
by runrig (Abbot) on Apr 30, 2003 at 18:36 UTC | |
Re: Parsing a Tagged File Format
by Aristotle (Chancellor) on Apr 30, 2003 at 14:23 UTC | |
Re: Parsing a Tagged File Format
by hossman (Prior) on May 01, 2003 at 01:00 UTC | |
Re: Parsing a Tagged File Format
by Anonymous Monk on Apr 30, 2003 at 11:00 UTC | |
by arunhorne (Pilgrim) on Apr 30, 2003 at 11:03 UTC |
Back to
Seekers of Perl Wisdom