in reply to Re^4: reading files to different output files.
in thread reading files to different output files.

Do I have to somehow open the input files in the script?

Yes.

open my $input_file, '<', $input_filename or die "Cannot open input fi +le $input_filename: $!.\n"; while (my $input_line = <$input_file>) { chomp $input_line; print "[$input_line]\n"; } close $input_file;

Replies are listed 'Best First'.
Re^6: reading files to different output files.
by ic23oluk (Sexton) on May 28, 2017 at 15:11 UTC
    the input file should come from the command line. i don't want to determine the file within the script. Doesn't <> within the while loop open the files the users enters in the command line? If not, how can i implement the open command in my script?
      Doesn't <> within the while loop open the files the users enters in the command line?

      Yes, and there's more to it. Read about the null filehandle in I/O Operators, there's much to learn about @ARGV, $ARGV and ARGV, all three being "magical".

      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

      shmem's guidance is spot on, as usual. Be careful about command line filenames with wildcards, as these are handled differently in Windows vs. Linux.