
digioleg54
User
Aug 24, 2016, 10:21 AM
Post #1 of 10
(3254 views)
|
How can I use @ARGV
|
Can't Post
|
|
I am trying to read arguments from command line, this way: #!/usr/bin/perl use strict; use warnings; my $file = $ARGV[1]; print "$file\n"; open (FL,"<$file") or die "Could not open file $file $!\n"; while(<FL>){ print "$_"; } My command line: perl readfile.pl file.txt it always show the errors: Use of uninitialized value $file in concatenation (.) or string at readfile.pl line 7. Use of uninitialized value $file in concatenation (.) or string at readfile.pl line 7. Could not open file ,No such file or directory at readfile.pl line 7. file.txt created on the same directory as my script. Version: This is perl 5, version 22, subversion 2 (v5.22.2) built for darwin-2level Can somebody explain me , why?
|