Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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

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

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

I bet you're invoking the program on the shell like:

$ perl

In which case the shebang doesn't matter, and never has. It only matters if you're doing:

$ ./

Or if you're executing it on a web server without an embedded interpreter (like mod_perl).

The shebang is a magic number (see man magic) which tells the operating system to execute the command on the line with the given options to intepret the rest of the file. Since the perl form already has an interpeter attached to the code, the #! is considered just another comment (sort of . . . )

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

Replies are listed 'Best First'.
Re: Re: What's #! got to do with it?
by Petras (Friar) on Jan 16, 2004 at 21:26 UTC
    Well, this is what happens when one is assimilated. When I ran .\ from a command (DOS) prompt, notepad opened with the script for editting :)

    Rats, foiled again!

    UPDATE: Even with correct shebang, calling the script from the DOS prompt via  .\ in win XP still launches notepad. Kinda makes you wanna launch windows...
    Don't worry about people stealing your ideas. If your ideas are any good, you'll have to ram them down people's throats.

    -Howard Aiken
      The shebang line doesn't matter on DOS/Windows, except for (CGI-)scripts for under Apache.

      You can fix that by changing the default action associated with the .pl extension. To do that you need to go to: explorer->tools->folder options->File Types->Extensions->PL->Advanced->Open->Edit

      If you set that to something like c:\Perl\bin\perl.exe" "%1" %* you will automatically invoke the perl interpreter rather than notepad.

      From this interface you can also add a separate option to be shown on right-click context menus. For example, you can set "Edit" as an option that uses notepad, but have it default to "Open" with the interpreter.

        Keep in mind that, at least on Win2k, that %* at the end will tell Windows to feed the entire rest of the line to your script, including redirects. So if you tried this:

        .\ > anotherfile.txt
        @ARGV would look like this:
        @ARGV = ('>', 'anotherfile.txt');
        and the output would not be redirected. For that reason, I always use the perl version on Windows, which will work correctly with redirects.


        Perl6 Grammar Student

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2022-11-30 19:50 GMT
Find Nodes?
    Voting Booth?