Monday, 14 January 2013

Perl Program


Perl Program

Interpreted – program is a text file
Portable – Unix, Mac OS X, Windows...
#!/usr/bin/perl -w
print "Hello world!\n";

Scalar Variables

Scalar: a number or string
Syntax: start with a $
Do not need to pre-declare variables
$x = 42;
$y = $x + 13;
$z = "hello";
undef and defined()
Variables are the value undef at first, use the defined() test
if (defined($z)) { ...

No comments:

Post a Comment