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

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.


Comment on Re: Shebang Inside the coding ?
Select or Download Code
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.

    Regards,
    S.Venni Rajan.
    "A Flair For Excellence."
                    -- BK Systems.</b
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 http://perldoc.perl.org/perlrun.html#ENVIRONMENT.
      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!

      cheers

      SK

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2014-07-25 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (169 votes), past polls