Simply open the files and use them (its best to open the input file first: if there's an error opening it, you don't want to create the output file).
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 (<IN>)
{
print OUT convert($_);
}
close OUT;
close IN;
If you're doing only simple conversions, then you don't need to put the formating in a subroutine; but it doesn't do any harm. --Dave. |