By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,983 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,983 IT Pros & Developers. It's quick & easy.

@ARGV not working with Windows Server 2003 service pack 2

P: 3
I cannot access command line variables, e.g. $ARGV[0], using perl on a Windows 2003 server with service pack 2.
Does anyone know of a bug or a work around?
Here's my test....
when I enter " hi", I get "no arguments".

Expand|Select|Wrap|Line Numbers
  1. #!c:\perl\bin\perl.exe
  3. if (defined($ARGV[0])) {
  4.     print "input parm=$ARGV[0]\n";
  5. } else {
  6.     print "no arguments\n";
  7. }
  8. exit;
Jul 26 '07 #1
Share this Question
Share on Google+
4 Replies

P: 3
I discovered that if I run the program prefaced with "perl", it works.
So it 'half' works without the "perl" preface (i.e. the second print statement works, so perl is running in some fashion), and it works completely if I use "perl" before the program name. I am guessing it is some sort of operating system defect. Any thoughts? (at least I have a work around)
Jul 26 '07 #2

Expert Mod 2.5K+
P: 3,503
As a general rule, on Windows, you should always issue your programs as:

c:\> perl [options]

Just stick to that and things will work better. If you really want to use the shebang and not have to use the above format, then switch to a *nix operating system such as Linux or Solaris.


Jul 26 '07 #3

P: 3
I discovered that the path environment variable had c:\perl\site\bin and c:\perl\bin. When I removed the c:\perl\site\bin entry, the problem was fixed.
Jul 26 '07 #4

Expert Mod 2.5K+
P: 3,503
Good to hear and thank you for the follow up!


Jul 26 '07 #5

Post your reply

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