Writing Your First Perl Program

This chapter starts with the Perl version of “Hello World.” The program is fairly simple, yet it introduces some basic elements of Perl (see Listing 2.1).

Listing 2.1. hello.pl
use strict; 
use warnings; 

print "Hello World\n";

The first line,

use strict;
tells Perl to turn on strict syntax and variable checking. This line should begin every program you write. Without it, Perl relaxes the syntax rules and lets you do things you really shouldn’t. (More on this later.)

The second line

use warnings;
turns on additional ...

Get Perl for C Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.