in reply to Using @ARGV
as:open my $fh, shift or die "Cannot open file: $!\n";
Also worth mentioning here to OP is that using Data::Dumper for debugging can be very useful (sort of trivial here, but a good general technique):# do all the assignments from ARGV here my $filename = shift @ARGV or die "A filename parameter is required"; # explicitly open for read; and make sure filename is in the error mes +sage for reference open FILE, '<', $filename or die "Cannot open file '$filename': $!\n"; while(<FILE>){ ... } close FILE;
Also note that further down the line you may want to check out any of the GetOpt or other modules that do nice command-line parameter processing for you...use Data::Dumper; die Dumper \@ARGV; # see what's really in there ...
|
|---|