Memos - Perl Helper

Types of data

	**$ : scalar**

In perl, pointer are also scalar

	**@ : array**

"@var" is about the whole array, but "$var[4]" is about the element at index "4"

	**% : hash**

"%var" is about the whole armapay, but "$var{key}" is about the element indexed by "key"

Sample

#!/usr/bin/env perl
use strict;
use warnings;
# A comment line 
print "Hello, world!";
my $name = "Flavinus";
my $age = undef;

String operators

  • lesser than: $a lt $b
  • greater than: $a gt $b
  • equals: $a eq $b
  • not equal: $a ne $b
  • lesser or equal: $a le $b
  • greater or equal: $a ge $b

Tips

	**Check script syntax** 
perl -c script.pm

Need the correct $PATH

	**Onliner syntaxes**
$var = 'value' unless ($var eq 'nop');

"//" is like "??" in php

$var = anyFunction() // 'alt-value';);