Clever website slogan
Home > Tech > Perl

Perl Notes


Chapter 2. Starting off with a Shebang

a shebang (also called a hashbang, hashpling, or pound bang) refers to the characters "#!" when they are the first two characters in a text file. *nix operating systems take the presence of these two characters as an indication that the file is a script, and try to execute that script using the interpreter specified by the rest of the first line in the file. For instance, perl scripts start with the first line:

#!/usr/bin/perl -w

Typically the path to perl is appended with "-w" to enable useful warnings. Run "perl -h" for a full list of supported parameters.

Creating a perl script

  1. Type "vi myscript.pl".
  2. Type "#!/usr/bin/perl" or "#!c:/perl/bin/perl" or whatever your path to perl is.
  3. Type your script and close vi (<esc>, :wq).
  4. Type "chmod 755 myscript.pl".

For example:

#!/usr/bin/perl -w print "Hello, world!\n";