#!/usr/bin/env perl use strict; use warnings; open(my $ifh, '<', 'infile.txt') or die($!); open(my $ofh, '>', 'outfile.txt') or die($!); while((my $line = <$ifh>)) { chomp $line; # do something to $line print $ofh $line, "\n"; } close($ifh); close($ofh); #### #!/usr/bin/env perl use strict; use warnings; use File::Copy; copy('infile.txt', 'outfile.txt') or die("Ooops, i messed up: $!");