Hi,

I thought this would be simple...

I want to supply the name of a file on the command line when executing a
script.  Unfortunately, I'm getting an error that says that @ARGV is
uninitialized.

How do you initialize @ARGV?  How do you specify command line arguments?

 

I'm using Windows XP, activestate Perl 5.8.3.

 

>From the Command Prompt:

C:\Perl\my_scripts>argv_test.pl cookies.txt

Use of uninitialized value in print at C:\Perl\my_scripts\argv_test2.pl
line 4.

Use of uninitialized value in open at C:\Perl\my_scripts\argv_test2.pl
line 5.

readline() on closed filehandle INFILE at
C:\Perl\my_scripts\argv_test2.pl line

6.

 

Quoting cookies.txt doesn't change the error message.

When I push a value onto @ARGV, the script works fine.

 

Any insight will be very appreciated.

 

Larry.

 

argv_test.pl

 

use warnings;

#push @ARGV, "cookie.txt"; # when uncommented script works fine.

my $name =  $ARGV[0];

print $name;

open (INFILE, $name); 

while (<INFILE>) {

print $_;

}

close INFILE;

 

 

Reply via email to