open (INFILE, "input.txt") or die "cannot open input: $!"; open (OUTFILE, ">output.txt") or die "cannot open output: $!"; while () { # note the < and > brackets s/foo/bar/sg; # no =~ needed for $_ # no m needed print OUTFILE; # no "$_\n" needed: $_ is automatic # and the \n is still in $_ (you # don't cho(m)p it... } close INFILE; close OUTFILE; #### perldoc -f open perldoc perlvar (look for the $/ entry) perldoc perlre (for info about regular expressions) #### -- Joost downtime n. The period during which a system is error-free and immune from user input.