PERL programming: the “shebang” line

Tutoring PERL beginnings, the details can be so important.  While the tutor now focuses to the Linux/Mac side, Windows users might do well to tune in.

Over my last few posts I’ve been discussing how to get started with PERL programming.  Of course, I’ve run parallel posts:  some have focused on Windows, others on Linux/Mac.  I hope you’ve all been successful in following the procedures I’ve offered.

Whichever world you reside in – assuming it is just one – knowing what’s going on in the other world often seems beneficial.  Therefore, I recommend the users of one operating system read the posts for the other, if only to realize how similar the procedures are.

Today’s emphasis is on the line

#!/usr/bin/perl

which is part of the script for Linux/Mac, but is conspicuously absent at the head of the script for Windows.

According to Robert Pepper’s Perl Tutorial, #!/usr/bin/perl is called the “shebang” line. (By the way: almost everything I know about PERL I learned from Robert Pepper.) He goes on to explain that under Unix systems (Linux is a derivative), the shebang line tells the file type so the computer knows how to execute it.

Windows, he continues, does not need a shebang line. However, a shebang line for the Windows script might look similar to this:

#!c:/strawberry/perl/bin/perl.exe

(The above shebang reveals the use of Strawberry Perl).

The line tells the location of the perl interpreter, which will execute the script. Once again, the line is not needed in Windows.

For Linux/Mac, however, you will see something like

#!/usr/bin/perl

at the head of a PERL script, and it is needed – on mine, anyway. Now you know why, whichever operating system you might use:)

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Tagged with: , , , , ,

Leave a Reply