# Standard setup stuff and file handle opening goes here while () { s#pattern#replacement#; } #### #!/usr/bin/perl use strict; use warnings; # Get and open the input and output files my $INFname = shift; open my $INFH, '<', $INFName or die "Can't open '$INFName' for input: $!"; my $OUTFName = shift or die "Missing filename(s)!\n"; open my $OUFH, '>', $OUTFName or die "Can't open '$OUTFName' for output: $!"; # Do the search and replace while (<$INFH>) { s/foo/bar/g; print $OUFH $_; }