perl - Filehandle open() and the split variable -
i beginner in perl. not understand following:
to write script can:
- print lines of file $source comma delimiter.
- print formatted lines output file.
- allow output file specified in command-line.
code:
my ( $source, $outputsource ) = @argv; open( input, $source ) or die "unable open file $source :$!";
question: not understand how 1 can specify in command line, upon starting write code text of output file.
i rely on redirection operator in shell instead, such as:
script.pl input.txt > output.txt
then simple case of doing this:
use strict; use warnings; while (<argv>) { s/\n/,/; print; }
then can merge several files script.pl input1.txt input2.txt ... > output_all.txt
. or 1 file @ time, 1 argument.
Comments
Post a Comment