Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Shebang Inside the coding ?

by vennirajan (Friar)
on Jan 16, 2006 at 05:54 UTC ( [id://523399]=note: print w/replies, xml ) Need Help??


in reply to Re: Shebang Inside the coding ?
in thread Shebang Inside the coding ?

If it is a comment means, then why does my editor (vim) showing in different color (green) ? ( White color for comments ) ?!?!?!?!
Doest it meant with editor ?

Regards,
S.Venni Rajan.
"A Flair For Excellence."
                -- BK Systems.

Replies are listed 'Best First'.
Re^3: Shebang Inside the coding ?
by brian_d_foy (Abbot) on Jan 16, 2006 at 06:01 UTC

    Syntax colorers sometimes get confused. It probably sees the #! at the beginning of any line instead of only matching for the first line. I'll have to add this to my list of things that are hard to do with syntax highlighters. :)

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
Re^3: Shebang Inside the coding ?
by blazar (Canon) on Jan 16, 2006 at 12:55 UTC

    Because your editor, whatever it is, however good it is, is not perl, and it is a well known axiom that "nothing but perl can parse Perl". So do not trust your editor's syntax highlighter. Trust your perl parser! Of course this simple case is on the border line, so to say, and probably other syntax highlighters do a better job of only marking a shebang looking like line like a shebang if it actually occurs at the beginning of the script. But in general expect similar "mistakes".

    Occasionally even perl has a difficulties parsing Perl and you need to help it by disambiguating suitably!

    Of course both the shebang line and a "regular" comment are just comments to perl itself. Well, not quite: I remember having read that perl does not fully trust the OS interpreting the shebang line and re-reads it, which is the reason why stuff like

    #!Perl -lpi.bak

    does work also under (osen that do not do shebang line interpretation, like) Windows.

      It's not a matter of "trusting". The kernel will only do something with the shebang line if 1) it's a Unix kernel and 2) the program was executed directly. Furthermore, not every kernel will do the same - different kernels have different limits on the number of significant characters.

      So, to make things equal, perl will pay attention the the first line - if it's a shebang line, it will look which command follows the shebang line. If it doesn't look like a perl, it will start this command, else it will look which options have been passed.

      It's also not a matter of re-reading. It has to read the first line anyway. (Other interpreters would just discard the first line - it's not a coincidence that interpreters (*) line Perl, shells and Python use the # as their comment character.

      (*) Called interpreter because they can read a program on their STDIN and execute it.

      Perl --((8:>*

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-04-24 00:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found