| Prev | Perl Notes |
Next |
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
- Type "vi myscript.pl".
- Type "#!/usr/bin/perl" or "#!c:/perl/bin/perl" or whatever your path to perl is.
- Type your script and close vi (<esc>, :wq).
- Type "chmod 755 myscript.pl".
For example:
#!/usr/bin/perl -w
print "Hello, world!\n";