Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: ARGV Problem

by tjdmlhw (Acolyte)
on Jan 06, 2006 at 16:39 UTC ( [id://521524]=note: print w/replies, xml ) Need Help??


in reply to Re: ARGV Problem
in thread ARGV Problem

The 'C:\>my_perl_script.pl arg1 arg2' does work when you have specified perl as the default for the pl extension and have included the shebang line in the script.

Replies are listed 'Best First'.
Re^3: ARGV Problem
by ikegami (Patriarch) on Jan 06, 2006 at 16:43 UTC

    Windows doesn't read the shebang line. Perl in Windows does parse the shebang line (unlike Perl in unix, which treats it like any other comment), but not for the reason you mentioned.

    Update: Corrected problems identified by Celada. Verification of what he/she said:

    $ uname -sr FreeBSD 5.4-RELEASE-p8 $ cat a.pl #!/usr/bin/perl -w print undef; $ a.pl Use of uninitialized value in print at ./a.pl line 2. $ perl a.pl Use of uninitialized value in print at a.pl line 2.

      Actually, perl does always parse the #! line, for two reasons:

      • To work around old, buggy, or limited kernels that pass the arguments from the #! line incompletely themselves, or not at all.
      • As a security precaution: if a script says it wants taint checks in the #! line (by having -T included there), but the -T switch was not in fact found on the real command line, perl will complain and die rather than run without taint checks.

      The relevant quote from the perlrun manpage:

      The #! line is always examined for switches as the line is being parsed. Thus, if you’re on a machine that allows only one argument with the #! line, or worse, doesn’t even recognize the #! line, you still can get consistent switch behavior regardless of how Perl was invoked, even if -x was used to find the beginning of the program.

      (but it's certainly an ugly hack that it does this. After all, the idea of the shebang was that the interpreters so invoked wouldn't even be aware of its existence.)

      Sorry to take so long to reply, but my wife called Friday while I was reading your message to say that our water heater had ruptured and the basement was flooded.

      The shebang was mentioned as way to cover the -w switched referenced in Corion's message. Sorry for the confusion.

      I would like to reload the perl on the XP box before continuing with this. Unfortunately, I am working from home today because of the plumbing problem and don't have access to the XP system.

      I will post what the results are as soon as I get perl reloaded.

Re^3: ARGV Problem
by Corion (Patriarch) on Jan 06, 2006 at 16:41 UTC

    No, it does not. It does not pass the arguments. As you found out.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://521524]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-04-19 11:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found