This should work (see code comments):
use strict;
# will use this variable to hold third
# column value of the last record.
my $last_val;
while(<DATA>) {
chomp;
next unless (m/.*<tab>.*<tab>\s*(\d{2,})/);
# third column value has changed?
print "\n" unless ($last_val == $1); # yes, skip to next line
print;
$last_val = $1;
}
__DATA__
0<tab>761<tab>94 (041352)
0<tab>2311<tab> 94 (0.00)
0<tab>27<tab> 94 (NG012)
0<tab>892<tab>94 (04/23/2002)
0<tab>494<tab> 94 (520-004)
1<tab>343<tab> 38 (info)
1<tab>133<tab> 38 (info)
1<tab>345<tab> 94 (info)
Here's the output I get:
0<tab>761<tab>94 (041352) 0<tab>2311<tab> 94 (0.00) 0<tab>27<tab> 94 (
+NG012) 0<tab>892<tab>94 (04/23/2002) 0<tab>494<tab> 94 (520-004)
1<tab>343<tab> 38 (info)1<tab>133<tab> 38 (info)
1<tab>345<tab> 94 (info)
|
"There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith
|
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.