So what if we want to run our program from the command line without having to type in the name of the Perl interpreter first?
You can make a file executable by typing:
% chmod +x hello.pl |
at the command line. (For more information about the chmod command, type man chmod).
In order to let the shell know what to do with our program when we try to run it with ./hello.pl from the command line, we put the following line at the top of our program:
#!/usr/bin/perl |
That's what we call a "shebang" line (because the # is a "hash" sign, and the ! is referred to as a "bang", hence "hashbang" or "shebang"). It tells the system what to use to interpret our script. Of course, if the Perl interpreter were somewhere else on our system, we'd have to change the shebang line to reflect that.