in reply to How can I parse grouped data?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I parse grouped data?
by Anonymous Monk on Jul 29, 2005 at 04:56 UTC |