|Syntactic Confectionery Delight|
Extracting and manipulating a range of linesby joeymac (Acolyte)
|on Oct 18, 2013 at 18:54 UTC||Need Help??|
joeymac has asked for the
wisdom of the Perl Monks concerning the following question:
Hello Magnanimous Monks,
I am attempting to rewrite some Bash scripts that use a lot of awk pipes into Perl. I am looking for the best way to read in information from a repetitive text file. The text file looks something like this:
And then the "pattern" repeats (many times) in the text file. The end result is to print it all out in neat columns with headers at the top, something like:
I started out putting the whole text into an array and grepping out what I want, put that was quickly becoming very messy. My second attempt is trying to extract multiple lines using the method:
I found my self wanting to then put it into an array as above but that will most likely end up being the same messy situation.
I would greatly appreciate any ideas or suggestions about an easy way to extract the bits of info that I want and print them out into the desire column format (using sprintf I reckon). Also as a side note, the Perl will need to be somewhat portable (i.e. it'll run under Windows, Linux, and OSX OS's).
Thanks in advance!