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

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -