use warnings; use strict; while(<DATA>) { #some conversions here if($_ =~ /<EMP>/g) { print; } } __DATA__ 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
Prints:
<EMP>P7 22 0.12 <EMP>P1 23 0.82
as expected. What's the problem?
Added:
Oh, and the /g (global) switch is not required - the first match in the line should be sufficient.
In reply to Re: Working with a text file
by GrandFather
in thread Working with a text file
by rsriram
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |