On Jun 2, Larry Wissink said:
>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?
You don't initialize @ARGV. It gets whatever arguments are passed to your
program. You send your program arguments by placing them after the
program name.
>C:\Perl\my_scripts>argv_test.pl cookies.txt
Have you tried calling it as
perl argv_test.pl cookies.txt
I'm just curious because I don't trust Windows.
>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;
That code looks ok to me.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
CPAN ID: PINYAN [Need a programmer? If you like my work, let me know.]
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>