Perl References arrays and hashes can only contain scalars (numbers and strings) if we want something more complicated (like an array of arrays) we use references references are scalars as well references are like pointers in C/C++
Creating References from existing variables: $scalar_ref = \$scalar_var; $array_ref = $hash_ref = \%hash_var;
Anonymous References anonymous arrays use []: $array_ref = [ 1, 2, [ “dog”, “cat”, “mouse” ] ]; anonymous hashes use {}: $hash_ref = { “height” => 175, “weight” => 67.8 }
Dereferencing scalar references: $$scalar_ref array references: $array_ref->[2] hash references: $hash_ref->{“height”}
Regular Expressions used to match patterns in strings most characters match themselves except for: \ | ( ) [ { ^ $ + ?. to match a special character, escape it with a \ e.g.: \\ \. \$
RE cont'd ^ matches the beginning of the string $ matches the end of the string. matches any character
RE quantifiiers * zero or more occurences + one ore more occurences ? zero or one occurences {n,m} between n and m occurrences {n,} at least n occurrences {n} exactly n occurrences
() in RE () used to group characers where more than a single character is to be quantified value matching pattern in () is stored for later use
Simple CGI Program #!/usr/bin/perl print "Content-type: text/plain\n\n"; print $ENV{"QUERY_STRING"};
Pattern Matching