sub convert { scalar reverse shift } # whatever my $infile = "infile.txt"; my $outfile = "outfile.txt"; open IN, "<$infile" or die "can't read $infile: $!"; open OUT, ">$outfile" or die "can't write $outfile: $!"; while () { print OUT convert($_); } close OUT; close IN;