You want to print out the side effect of having performed the operation, which is captured in the variable $_ that your substitution operated on. Perform the substitution on $_ and then print $_.
while (<IN>){ if (/^call started/) { s/^call.*total/Modem Line 0\/$i : /; print OUT "$_\n"; $i++; } }
Tom Moertel : Blog / Talks / CPAN / LectroTest / PXSL / Coffee / Movie Rating Decoder
In reply to Re: while loop, search, and replace while loop, search & replace
by tmoertel
in thread while loop, search & replace
by PJT
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |