in reply to Extracting formatted text block
EDIT: I updated my code for the wrapping text and for reading line by line instead of all at once.
use strict; use warnings; my (@col1, @col2); do {} until index(<DATA>, 'INTERESTING CODE') != -1; <DATA> for (0..1); while (<DATA>) { $_ .= ' ' x (67 - length $_); @_ = unpack 'x2A8x1A23x1A8x1A23', $_; push @col1, $_[1] if $_[0]; push @col2, $_[3] if $_[2]; } print '"' . join(', ', @col1, @col2) . '"'; __DATA__ blah blah blah blah blah blah blah blah blah blah blah blah INTERESTING CODE-- CODE NAME CODE NAME -------- ----------------------- -------- ----------------------- ABC NAME ONE RST NAME EIGHT ... DEF NAME TWO THREE WXY NAME NINE - TEN GHIJK NAME FOUR ... ZAB NAME ELEVEN LMN NAME FIVE - SIX CDE NAME TWELVE OPQ NAME SEVEN more blah blah blah
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Extracting formatted text block
by punkish (Priest) on Mar 17, 2005 at 01:30 UTC |