O'Reilly logo

Sams Teach Yourself Perl in 21 Days, Second Edition by Rafe Colburn, Laura Lemay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Another Example: Create Hello World As a Script

Now let's do the same thing, only this time we'll create Hello World as a separate file and execute the script that way. You'll need a text editor. Not a word processor, but specifically an editor just for text: emacs, vi, or pico are just fine for Unix; use Notepad or the shareware programs TextEdit or UltraEdit on Windows; you can use SimpleText BBedit or any of the mentioned Unix tools on Mac OS X.

Create Hello World as a Script

Fire up your text editor and type the two lines shown in Listing 1.1 (well, three if you count the blank one in the middle).

Listing 1.1. The hello.pl Script
1: #!/usr/bin/perl -w
2:
3: print "Hello, World!\n";

Note

Don't type the numbers at the beginning of the lines ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required