in reply to while loop, search & replace

What you're doing is printing the result of the substitution operation, and that's not what you think it is. The s/// operator returns the number of substitutions it performed, which in your case is always 1.

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