Your skill will accomplish what the force of many cannot |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
G'day bhargavkanakiya, You say you're OK with the file handling. Here's my solution for the data handling.
Here it is on the commandline: $ perl -Mstrict -Mwarnings -E ' my @buffer; my @input = <>; say "========\n Output\n========"; for (@input) { push @buffer, $_; next if /SIL\s*$/m; print shift @buffer while @buffer; } print $buffer[0] if @buffer; ' 0.642375 125 SIL 1.0705 125 ઔર્ 1.3651875 125 આત્ 1.519875 125 મ 7.2140627 125 સે 7.478125 125 હટ્ 7.622625 125 જા 7.956125 125 ઓ 8.192375 125 SIL 8.252 125 SIL 8.464 125 SIL 8.706 125 SIL ======== Output ======== 0.642375 125 SIL 1.0705 125 ઔર્ 1.3651875 125 આત્ 1.519875 125 મ 7.2140627 125 સે 7.478125 125 હટ્ 7.622625 125 જા 7.956125 125 ઓ 8.192375 125 SIL I found some lines had additional whitespace at the end: this may be valid data; a result of your cut-n-paste operation; related to all those special characters; or, something else. Anyway, I used the /SIL\s*$/m regexp to get around this — you may want to modify that for your real-world application. -- Ken In reply to Re: removing lines that are in the end of a file
by kcott
|
|