Presentation is loading. Please wait.

Presentation is loading. Please wait.

Perl Practical(?)‏ Extraction and Report Language.

Similar presentations


Presentation on theme: "Perl Practical(?)‏ Extraction and Report Language."— Presentation transcript:

1 Perl Practical(?)‏ Extraction and Report Language

2 Syntax free form all statements end in ; comments begin with # and continue to the end of the line loosely typed

3 Scalar Literals integers: 1, -34, 12345 floating point: 3.14, 6.02e23 strings: 'it was a quit day', “for all the quitters”

4 Scalar variables begin with $ don't need to declare before use $answer = 42; $pi = 3.14; print $answer, $pi; $pi = “apple” print $pi;

5 Arrays list of scalar values grouped by parentheses and separated by commas ( 27, 34, 128, 5 )‏ ( “dog”, “cat”, “mouse”, “houe” )‏ ( 3.14, “water”, -27, 6.02e23 )‏

6 Array Variables begin with @ get/set length with $# @home = (“couch”, “chair”, 23 ); ($a, $b, $c) = @home; $home[0] = “stove”; print $home[2]; print $#home;

7 Hashes (Associative Arrays)‏ pairs of associated values uses array notation or => ( “k”, “kilo”, “M”, “mega”, “G”, “giga” )‏ ( “k” => “kilo”, “M” => “mega”, “G” => “giga” )‏

8 Hash Variables begin with % %SI_prefix = ( “k” => “kilo”, “M” => “mega”, “G” => “giga” ); $SI_prefix{“c”} = “centi”;

9 Operators Arithmetic: +, -, *, /, % (modulus), ** (exponentiation)‏ String:. (concatenation), x (multiply)‏ relational:  arithmetic, =, ==, !=,  string: lt, gt, le, ge, eq, ne, cmp Logical: &&, ||, !, and, or not

10 Truth any string is true except for “” and “0” any number is true excep for 0 any undefined value is false

11 Type Conversion Perl freely converts between numbers and strings as required by the given operator e.g 1 + “24.7” 1. 24.7 1 + “foo”

12 Interpolation strings in single quotes '' are interpreted as is strings in double quotes “” are interpreted by first substituting any variable references in the string with their actual values $pref = “k”; $new_str = “My $home[0] weighs $SI_prefix{$pref}grams”;

13 Control Flow if, elsif, else while for foreach breaking out of loops: next, last

14 Subroutines take an arbitrary list as args, stored in @_ can return an arbitrary list local variables declared with my


Download ppt "Perl Practical(?)‏ Extraction and Report Language."

Similar presentations


Ads by Google