Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: text processing

by sundialsvc4 (Abbot)
on Apr 22, 2014 at 18:22 UTC ( #1083213=note: print w/ replies, xml ) Need Help??


in reply to text processing

This sort of problem is, actually, extremely common.   It is, in fact, the inspiration for the awk tool that was one of the original inspirations for Perl.

In general, problems like this one can solved “text line by text line,” and can be reduced, algorithmically speaking, to four cases, all of which can (somehow) be recognized by the contents of the line (and/or by “beginning of file” and/or “end of file”):

  1. A record which marks the start of some area-of-interest.   Such as, in this case, TABLE.
  2. A record which marks the end of an area (and the generation of output based on accumulated data), such as END.
  3. A record which marks data to be gathered in-memory in anticipation of future output, such as DATAnn.
  4. A record whose presence is expected but otherwise uninteresting, such as HEADn.

Your immediate requirement could actually be addressed entirely by awk, and nothing else, and perhaps for this very reason you might elect to do so.   In any case, the man-page hyperlinked above should now be read carefully and thoroughly.


Comment on Re: text processing

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2014-11-24 03:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (135 votes), past polls