in reply to Extracting formatted text block

Those are evidently fixed-width fields, so unpack is a likely choice.

while (<DATA>) { # seek interesting stuff . . . while (<DATA>) { last if /^\n/; my (@codes,@names); ($codes[0],$names[0],$codes[1],$names[1]) = unpack 'xx A8 x A23 xx A8 xxx A22', $_; push @interesting_stuff, grep {$_} @names; } }
The unpack format may not be exactly right for your real data, but it matches what I think I see here (I'd expect the two records in a line to have the same format).

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Extracting formatted text block
by ikegami (Patriarch) on Mar 16, 2005 at 23:33 UTC

    Two problems:

    1) Your solution doesn't take account lines that only have one column:
    x outside of string at !.pl line 28, <DATA> line 14.

    2) Your output not ordered correctly (if I fudge the data to get around the first problem):
    NAME ONE, AME EIGHT ..., NAME TWO THREE, AME NINE - TEN, NAME FOUR ..., AME ELEVEN, NAME FIVE - SIX, AME TWELVE, NAME SEVEN, XXX XXXXXX