How Perl Saved my Day
Previous First Next

Example 1: Print one line of text

Code

#!/usr/local/bin/perl
print "Mr. Livingstone, I presume?\n";

Comment

All Perl scripts should start with a line of the form
#!/usr/local/bin/perl
telling the operating system the name and location of the Perl intepreter. In this case, it's in the directory /usr/local/bin/ and called perl.
[Note 1]

The line
print "Mr. Livingstone, I presume?\n";
does what you'd expect: it prints a line of text to standard output
[Note 2]. \n is a special character (because it starts with the backslash \) and causes a new line to be started.

By the way: lines starting with # are comment lines and discarded by the Perl interpreter.


Previous First Next
10.12.1998 Michael Gfeller