use warnings; use strict; reader($_) for (@ARGV); sub reader { my ($filename) = @_; open my $fout, '>>', 'output_file.txt' or die "can't open file: $!"; open my $fh, '<', $filename or die "can't open file: $!"; while (<$fh>) { print $fout $_; } print $/; }