469,362 Members | 2,435 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

ARGV doesn't work on Windows 2008?

dlite922
1,584 Expert 1GB
A script stopped working when I moved it from Win 2003 server to Win 2008. After some troubleshooting it seems that it was not grabbing the command line parameters.

So I did a print $ARGV and exit at the beginning of the file and I get this:

Expand|Select|Wrap|Line Numbers
  1. Use of uninitialized value $ARGV at .... line X
  2.  
I'm using perl from a folder, not installed or in window's path.

Thanks!


Dan
Oct 12 '10 #1

✓ answered by RonB

It's been my experience that this is a common problem when the OP has never installed perl and is using a port which makes you set these types of settings without a supplying any defaults.

The action attribute of the open setting within the file type association should be set to something like this:
"C:\Perl64\bin\perl.exe" "%1" %*
The key part being:
"%1" %*
which sets/allows for the acceptance of the script arguments aka @ARGV. Calling the perl interpreter directly and passing it the script and args will "get around" the problem, but is not the best/proper solution.

10 3368
RonB
589 Expert Mod 512MB
$ARGV is a scalar variable. What you're wanting is @ARGV which is an array.

I you want to post your script and how you're executing it, we should be able to find the problem.
Oct 12 '10 #2
dlite922
1,584 Expert 1GB
Sorry, that's a PHP->Perl mistake.

There isn't any script, just this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. print "Testing ARGV...\n"; 
  3. print @ARGV;
  4. print #$ARGV;
  5.  
  6.  
It prints an empty line after that message of course.
Oct 13 '10 #3
RonB
589 Expert Mod 512MB
Syntax error, change:
Expand|Select|Wrap|Line Numbers
  1. print #$ARGV;
to:
Expand|Select|Wrap|Line Numbers
  1. print $#ARGV;
Or a better method to see what's in the array.
Expand|Select|Wrap|Line Numbers
  1. use Data::Dumper;
  2. print Dumper \@ARGV;
Oct 13 '10 #4
dlite922
1,584 Expert 1GB
yes, that was a typo, I apologize. It remains the same though, still doesn't work.

Whatever it takes to convince you :)

here's my file now:

Expand|Select|Wrap|Line Numbers
  1. use Data::Dumper;
  2. print Dumper \@ARGV;
  3.  
Here's the output on Win 2k8:
Expand|Select|Wrap|Line Numbers
  1. C:\>test.pl test test test
  2. $VAR1 = [];
  3.  
Weird huh? Code works fine on my XP PC.

Output On XP:
Expand|Select|Wrap|Line Numbers
  1.  
  2. C:\tmp>test.pl test test test
  3. $VAR1 = [
  4.           'test',
  5.           'test',
  6.           'test'
  7.         ];
  8.  
  9.  
  10.  
I'm out of ideas. Googled with no avail.


Dan
Oct 13 '10 #5
RonB
589 Expert Mod 512MB
Your file type association is not setup correctly.

Run a test by executing your script like this:
C:\>perl test.pl test test test
Oct 13 '10 #6
numberwhun
3,503 Expert Mod 2GB
This is most puzzling because I have worked on both windows platforms you mentioned, doing Perl development of course, and never experienced this issue. I am anxious to see what happens with Ron's last suggestion.
Oct 13 '10 #7
RonB
589 Expert Mod 512MB
It's been my experience that this is a common problem when the OP has never installed perl and is using a port which makes you set these types of settings without a supplying any defaults.

The action attribute of the open setting within the file type association should be set to something like this:
"C:\Perl64\bin\perl.exe" "%1" %*
The key part being:
"%1" %*
which sets/allows for the acceptance of the script arguments aka @ARGV. Calling the perl interpreter directly and passing it the script and args will "get around" the problem, but is not the best/proper solution.
Oct 14 '10 #8
numberwhun
3,503 Expert Mod 2GB
Agreed! Lets see what happens when they run it.
Oct 14 '10 #9
dlite922
1,584 Expert 1GB
Ron was exactly right.

I half-heatedly explained that perl is not installed, but since it "worked" I didn't have any technical reasons why ARGV wouldn't work.

It does have to do with file association, because like he said when I gave my file to perl.exe it worked!

Expand|Select|Wrap|Line Numbers
  1.  
  2. C:\temp\Perl64\bin>perl.exe C:\test.pl test test test
  3. $VAR1 = [
  4.           'test',
  5.           'test',
  6.           'test'
  7.         ];
  8.  
  9.  
Awesome! Thank you.

Why not installed? This is a loaned/borrowed server and want to return it in the same exact shape I got it. (Running everything from inside a folder makes for easy cleanup later)

Thanks guys,


Dan
Oct 14 '10 #10
numberwhun
3,503 Expert Mod 2GB
I am certainly glad that Ron's suggestion was the issue. On another note, specifically the issue of returning the server in the condition you found it, portable apps are your friend. In fact, Strawberry Perl has a portable version that you can put on a stick. Enjoy!
Oct 16 '10 #11

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Sourcerer | last post: by
7 posts views Thread by Sin Jeong-hun | last post: by
4 posts views Thread by =?Utf-8?B?QXZhRGV2?= | last post: by
1 post views Thread by Andy B | last post: by
3 posts views Thread by =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.