Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: What's #! got to do with it?

by Coruscate (Sexton)
on Jan 16, 2004 at 21:20 UTC ( #321913=note: print w/replies, xml ) Need Help??


in reply to What's #! got to do with it?

I'm going to assume you were executing the script as "perl foo.pl" on the command line. If so, you are executing the perl executable (which just happens to be the same path as you'd put on the shebang line). The shebang line becomes necessary if you want to execute the script via "./foo.pl" on the command line. Because in this case, you are executing the actual script itself (via the shell), and the shell has to know which program to use to interpret the file.

Essentially, try one of your "magic" scripts by executing a "chmod 755 foo.pl" on it and then run "./foo.pl". It won't work (unless the valid perl path is placed as the first shebang line). The rest of the shebang lines aren't actually shebang lines. perl comments begin with '#', so all other "shebang lines" are really just plain old comments.

Replies are listed 'Best First'.
Re: Re: What's #! got to do with it?
by hardburn (Abbot) on Jan 16, 2004 at 21:25 UTC

    so all other "shebang lines" are really just plain old comments.

    Not quite. It might still try to parse that line for options. Which is why you can still get the Too late for "-T" option at taint_test.pl line 1. error when calling a program as perl file.pl with -T set on the file's shebang line.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

      Not quite. It might still try to parse that line for options. Which is why you can still get the Too late for "-T" option at taint_test.pl line 1. error when calling a program as perl file.pl with -T set on the file's shebang line.

      That's why I said qq{so all the other "shebang lines"} (ie: any shebang lines following the first one) :)

        That is not true, either. For instance,
        #line 500 "Source file"
        will set tokens __LINE__ to 500 and __FILE__ to Source file. See pp. 618-619 in the Camel, 3rd ed.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2022-11-29 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?