On Wednesday 23 June 2004 10:22 am, PerlDiscuss - Perl Newsgroups and mailing 
lists wrote:
> I am a new perl user and I am running into a problem.  I am trying to use
> argv and it's not returning the correct response on my laptop, but it's
> working fine on another machine.  The only difference between the two
> machines is that on my laptop, I first installed the perl AS package for
> windows rather than the MSI package from
> http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl
> However I tried to uninstall the AS package and installed the MSI but it's
> still doesn't work.  On the other machine that works, I only install the
> MSI package.  Not sure if that made any difference.
>
> test.pl
> $test= @argv[0];
> die "nothing in array" if (!$test);
> print $test;
>
> c:\test.pl one two
>
> expected: (this is what I get on my other machine)
> onetwo
>
> Problem: (this is what I get on my laptop)
> nothing in array at C:\myperl\test.pl line 2.
>
> Any help will be greatly appreciated!

Try @ARGV (all caps) - that is what it should be.
I don't know why @argv works at all. Pulling an element
from an array should use '$':

 $ARGV[0] -not- @ARGV[0]

Also, get in the habit of starting all your scripts with:

use strict;
use warnings;

my $test= $ARGV[0];                   # proper format
die "nothing in array" unless $test;  # unless is easier to read
print $test, "\n";                    # added newline


Aloha => Beau;



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to