> perl script.pl
Alternatively, put the location of you Perl interpreter (this may vary from system to system use: which perl) in first line of your script. It tells the machine what to do when the file is executed (run the file through Perl):
#!/usr/bin/perl -wThe -w option enables the output of warnings.
#!/usr/bin/perl -w # # Program "Hello world" # print 'Hello world'; # Print a messageComments can be inserted into a program with the # symbol (this is the only way),
print FILEHANDLE LISTIf FILEHANDLE is omitted, prints by default to standard output (or to the last selected output channel--see "select"). If LIST is also omitted, prints $_ to the currently selected output channel.
You can use parentheses for function arguments or omit them
(they are required occasionally to clarify precedence).
print("Hello, world\n");
print "Hello, world\n";
print "Hello", "world\n";
print "Hello
world"; # linebreak in the middle
$name = "fred"; print "Hello, $name\n"; # works fine print 'Hello, $name\n'; # prints $name\n literally
print 42;
print { $file } "stuff\n";
print { $OK ? STDOUT : STDERR } "stuff\n";
print accepts scalars, strings, lists, arrays and hashes as arguments.
To print formated you can use the C-like printf function.