Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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.

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 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

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://523401]
help
Chatterbox?
[ambrus]: overhead transparencies are a nice convenience by the way that mix the two slides, because you can write them in advance and edit them during the presentation easily. but they're not very much in fasion these days.
[ambrus]: you can even print them.
[Discipulus]: ambrus i'm trying out MremoteNG which wrap putty and rdp and many other things..
[Corion]: ambrus: Yes, ideally you would have the ease of overhead projection transparencies and pens drawing on them, combined with the computer generated slide text...
[Corion]: Maybe the solution would be a tablet (with pens), like the Wacom tablets, but you still need good software and need to know how to operate it well in an interactive setting ;)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2017-09-26 10:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (293 votes). Check out past polls.

    Notices?