in reply to Re^2: Unable to write output to file taken as input from command line
in thread Unable to write output to file taken as input from command line
To collect the file names from the command line, replace
print "Enter file name:\n"; chomp(my $file = <STDIN>); open(DATA,$file);
with
chomp(my $infile = shift); open(DATA,$infile) or die "Could not open $infile\n";
Add
chomp (my $outfile = shift); open OUTPUT, '>', $outfile or die "Could not open $outfile\n";
before the final for loop. Replace
printf "%-4s: %20s, %-8s %6s\n",
with
printf OUTPUT "%-4s: %20s, %-8s %6s\n",
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Unable to write output to file taken as input from command line
by graff (Chancellor) on Jul 25, 2014 at 02:48 UTC |