Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: /usr/bin/env perl - query

by JavaFan (Canon)
on Oct 13, 2008 at 09:38 UTC ( [id://716773]=note: print w/replies, xml ) Need Help??


in reply to Re: /usr/bin/env perl - query
in thread /usr/bin/env perl - query

And rightly so, assuming you're on Unix.

On Unix, the first two bytes of an executable are "magical" - they tell the kernel what kind of executable it is. It may be a binary (depending on the OS, it may be able to run different styles of binaries), or it may be something that's to be fed to an interpreter. The magical bytes to signal that are 0x23 0x21, which in ASCII looks like "#!". Then the kernel takes the rest of the line (up to the next horizontal whitespace, or newline) as the name of the interpreter to run, and then feed the program as its input.

So, if your program starts with

#! perl
and execute the program, the kernel will try to execute "perl" (assuming your OS skips leading whitespace; your program is more portable if it doesn't have whitespace after the #!). But the kernel isn't going to peek in your environment settings, and won't try all the directories in your $PATH. So it won't find "perl".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-24 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found