Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: process multiline text and print in desired format

by Fletch (Bishop)
on Mar 17, 2021 at 14:39 UTC ( [id://11129832]=note: print w/replies, xml ) Need Help??


in reply to process multiline text and print in desired format

You only ever do anything (print the line) for the "header" line of each of your blocks. Two approaches that come to mind:

  • Keep reading the file line by line, but implement a small state machine. Start off looking for the release line; once you've seen that look for column values (stashing them off in a hash) until you encounter a blank line. When you get the blank line your "record" is complete, so dump out the output line information you've accumulated (clearing out the state back to a default) and start looking for the next release.
  • Since your sample data looks amenable to it, use $/ to read in paragraph mode (see the entry for it in perlvar) and then parse things out from that record text.

The cake is a lie.
The cake is a lie.
The cake is a lie.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129832]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-24 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found