But for some tasks it may be overkill, and this may be one of those tasks. You just want to keep a selected subset of features from the input file and format them a little differently for output. If the input is consistent in its structure and format, like your examples, then here's a different sort of hint:
Read up on the "s" regex modifier and other useful tricks in "perldoc perlre" to work out how you want to handle the other items you're after in each record.{ local $/ = "}\n"; # end-of-record string # (might need "}\r\n", if data is CRLF style) while (<>) # this reads a whole multi-line record { my ( $cellname ) = ( /^\s*cell\s+(\S+)/ ); my ( $area ) = ( /area\s+(\d+)/ ); # and similarly for other items of interest... # print according to taste } }
Of course, if your input file format varies significantly from the examples you showed, this sort of approach will tend to be easy to break. Good luck.
In reply to Re: How can I parse grouped data?
by graff
in thread How can I parse grouped data?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |