in reply to editing files with (<>)

If you manually close ARGV when you get to eof of a particular file (see eof), $. restarts at 0. Another thing you can do is check when a new file is opened (@ARGV will have one less element, the filename stored in $ARGV will be changed.)

By the way, there seems to be no reason for you to do the s///, since you aren't printing the line.

Replies are listed 'Best First'.
Re^2: editing files with (<>)
by Aristotle (Chancellor) on Dec 21, 2004 at 08:05 UTC

    That would all be useful advice if he were doing this as a -n oneliner. Since he's not, he can simply loop file by file as I outlined above. No need to complicate the solution overly.

    Makeshifts last the longest.