in reply to shebang line
Not stupid, just not necessarily Perl. The shebang line is a UNIX-ism.
On UNIX-en (includes Linuxen as well) when you attempt to execute any file (any file, that is, which is has its executable bit set), the shell "peeks" at the first two characters lokoing for the shebang combination, "#!". If it finds them, it reads the remainder of the line up through, but not including, the terminating newline.
It breaks apart whatever it finds into tokens, split by whitespace, and calls exec() with the first token as the command, and the remaining tokens passed as arguments (in much the same way it does with manually typed commands at the prompt), and with the current filename (i.e., '/path/whatever.pl') appended to the list of arguments.
The exec() call normally causes the current process image (i.e., the shell) to be replaced with that of the command line (say, Perl). And away we go executing whatever script you've run with the appropiate interpreter.
OK, enough background. That explains what happens when you type 'whatever.pl' at the shell prompt.
Now, for your question: If the shebang line invokes Perl on the file, it will examine the shebang line itself to pick up any options that may not have made it through the command lne passed by the original shell (some UNIX-en have an arbitrarily short limit on the number of characters they can accept on the shebang line -- occasionally as few as 32), and will then start reading/compiling the perl code, including processing requires and/or uses, as necessary.
Any shebang lines in THOSE files will not be looked at, AFAIK, (although perl may actually honor any '-w' switches in them--I forget, exactly).
Update: Apparently, Perl will try to honor any -T switches (as insofar as they have to match the taint-mode-ness of the main .pl file).
dmm
You can give a man a fish and feed him for a day ...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: shebang line
by perlmongrel (Acolyte) on Jan 04, 2002 at 03:00 UTC | |
by mr_mischief (Monsignor) on Jan 04, 2002 at 07:09 UTC | |
by dmmiller2k (Chaplain) on Jan 04, 2002 at 03:09 UTC | |
by riffraff (Pilgrim) on Jan 04, 2002 at 04:56 UTC | |
by helgi (Hermit) on Jan 04, 2002 at 16:36 UTC | |
by dmmiller2k (Chaplain) on Jan 04, 2002 at 21:07 UTC | |
by perlmongrel (Acolyte) on Jan 05, 2002 at 03:09 UTC | |
not the shell
by Anonymous Monk on Jan 04, 2002 at 04:10 UTC | |
by dmmiller2k (Chaplain) on Jan 04, 2002 at 21:17 UTC | |
Re: Re: shebang line
by frag (Hermit) on Jan 04, 2002 at 04:41 UTC | |
by dmmiller2k (Chaplain) on Jan 04, 2002 at 21:09 UTC | |
by frag (Hermit) on Jan 04, 2002 at 21:16 UTC |