Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Shebang Inside the coding ?

by sk (Curate)
on Jan 16, 2006 at 05:57 UTC ( #523401=note: print w/replies, xml ) Need Help??

in reply to Shebang Inside the coding ?

Shebangs is meaningful only on the first 2 bytes in the first line of a file.

#!/usr/bin/perl print "hi\n";

call that prog "hi" and try to chmod +x on it and run it. It will work fine. (of course assuming the path to perl is correct) Now add a blank line above #!. Try to run this again. What do you see? Also try to add a space before shebang. what happens now?

Vim is not looking to see if the shebang is on the first line or not. That's why it is coloring it.

In short, that line is just a comment if it is in the middle of the code. -SK

Update: Please see ysth's reply on how shebang can have other stuff before it.

Replies are listed 'Best First'.
Re^2: Shebang Inside the coding ?
by ysth (Canon) on Jan 16, 2006 at 08:09 UTC
    Shebangs is meaningful only on the first 2 bytes in the first line of a file.
    Not always. Perl's -x switch allows you to run a program that has other garbage before it (e.g. the program is embedded in an email message), and expects to find the #! line partway into the file. See just above
      Thanks ysth. I totally forget about that switch. Now I remember how people use to make jpeg files print JAPH but putting the shebang at the end of the jpeg file and running the jpeg file through -x. Thanks for catching this!



Re^2: Shebang Inside the coding ?
by vennirajan (Friar) on Jan 16, 2006 at 06:11 UTC
    Dear All,
    Thanks For Sharing your Ideas with Me. I got enough knowledge about sha bang as well its functionalities.

    S.Venni Rajan.
    "A Flair For Excellence."
                    -- BK Systems.</b

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://523401]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2017-02-24 04:07 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (351 votes). Check out past polls.