rsriram has asked for the wisdom of the Perl Monks concerning the following question:
Hello all,
I am working with a tab separated text file and I need to do some s/r in it, followed by writing the file into another text file if there is tag <EMP>. I used the following code.
while(<F1>) { #some conversions here if($_ =~ /<EMP>/g) { print F2 $_; } }
When I did this in the file F2, there was only the <EMP> and the word following it. I need to print the whole line of text if <EMP> is encountered. Below are few lines from the files which I am working with.
PT 23 0.05 PK 27 0.21 <EMP>P7 22 0.12 PP 21 0.22 P3 21 0.20 P1 21 0.92 <EMP>P1 23 0.82 P2 22 0.12
In my output file, I should have only the two lines which begins with <EMP>.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Working with a text file
by citromatik (Curate) on Jun 05, 2007 at 11:26 UTC | |
|
Re: Working with a text file
by GrandFather (Saint) on Jun 05, 2007 at 11:43 UTC | |
|
Re: Working with a text file
by ww (Archbishop) on Jun 05, 2007 at 12:13 UTC |