in reply to How to pass a file to GetOpt

Your GetOptions call puts the pathnames of the files in the variables $input and $output. So now you just need to open those files and do stuff with them:

open my $in, '<', $input or die $!; open my $out, '>', $output or die $!; while(<$in>){ # do stuff to $_ print $out $_; # or whatever output you come up with }

Aaron B.
Available for small or large Perl jobs; see my home node.

Replies are listed 'Best First'.
Re^2: How to pass a file to GetOpt
by Anonymous Monk on Jul 10, 2012 at 23:26 UTC

    Aaron, I am getting an error: "No such file or directory at 5MinInterval2.pl line 11" Line 11 contains:

    open my $in, '<', $input or die $!;

    Any ideas as to why?

      Hi,

      Change

      open my $in, '<', $input or die $!; to open my $in, '<', $input or die "$! - [$input]";

      to see what you are actually trying to open.

      J.C.

        No such file or directory - [C:\Users\Mruppe2\workspace\Perl] at 5MinI +nterval2.pl line 11.

        The actual file path is longer than that. The error_log is actually just a file, I don't believe that it has an extension.

        perl 5MinInterval2.pl -input C:\Users\Mruppe2\workspace\Perl 5 Essen +tial Training\MPMStats Project\error_log -output C:\temp\output9.csv