GENERAL building blocks |
||
#!... | Location of interpreter | #!/usr/local/bin/perl # Path to interpretor |
strict | Restrict uGeneral C coding notes and Examplesnsafe constructs | use strict; # Module |
warnings | Control optional warnings | use warnings; # Module |
# | Comment |
$a+=$b;
# this is a comment # this is a comment # ##################this is a comment######################## |
; | Line terminator |
$a+=$b;
#each statement must $a=$a+ # end with a semicolon $b+ $b; |
$ | Scalars variable |
$a=1;
# Scalar variables
$b="This is text"; |
@ | Array variable |
@array=("Fred",253,"Driver",165,120); # Array
assignment # 0 1 2 3 4 # Element indicies $array[5]="New data"; # Elements added after the fact Print $array[2]; # Prints "Driver" Print @array; # Prints the entire array |
% | Hash variable |
%keywords=(one => "Number one",
# Essentially a translation table two => "Numbwr two", Three => "Number three"); Print "It's element $keywords'one'."; # prints "It's element Number one." |
Any questions or comments?
This page last updated on
September 04, 2011