Download presentation
Presentation is loading. Please wait.
Published byAriel Freeman Modified over 9 years ago
1
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++
2
Creating References from existing variables: $scalar_ref = \$scalar_var; $array_ref = \@arrary_var; $hash_ref = \%hash_var;
3
Anonymous References anonymous arrays use []: $array_ref = [ 1, 2, [ “dog”, “cat”, “mouse” ] ]; anonymous hashes use {}: $hash_ref = { “height” => 175, “weight” => 67.8 }
4
Dereferencing scalar references: $$scalar_ref array references: $array_ref->[2] hash references: $hash_ref->{“height”}
5
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.: \\ \. \$
6
RE cont'd ^ matches the beginning of the string $ matches the end of the string. matches any character
7
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
8
() 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
9
Simple CGI Program #!/usr/bin/perl print "Content-type: text/plain\n\n"; print $ENV{"QUERY_STRING"};
10
Pattern Matching
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.