in reply to reading/writing line by line

open (INFILE, "input.txt") or die "Can't open input.txt: $!\n"; open (OUTFILE, ">output.txt") or die "Can't open output.txt: $!\n"; while (<INFILE>) { s/foo/bar/g; print OUTFILE; }

I removed the /m and /s options from your s/// operator as they have no effect on data that doesn't contain newlines.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg