CS 330 Programming Languages 09 / 25 / 2008 Instructor: Michael Eckmann.

Slides:



Advertisements
Similar presentations
A Guide to Unix Using Linux Fourth Edition
Advertisements

CS 330 Programming Languages 09 / 27 / 2007 Instructor: Michael Eckmann.
COMP234 Perl Printing Special Quotes File Handling.
CS 106 Introduction to Computer Science I 09 / 25 / 2006 Instructor: Michael Eckmann.
CS 330 Programming Languages 10 / 14 / 2008 Instructor: Michael Eckmann.
Introduction to Perl Bioinformatics. What is Perl? Practical Extraction and Report Language A scripting language Components an interpreter scripts: text.
CS 106 Introduction to Computer Science I 02 / 04 / 2008 Instructor: Michael Eckmann.
CS 898N – Advanced World Wide Web Technologies Lecture 8: PERL Chin-Chih Chang
CS311 – Today's class Perl – Practical Extraction Report Language. Assignment 2 discussion Lecture 071CS Operating Systems I.
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
CS 106 Introduction to Computer Science I 01 / 30 / 2008 Instructor: Michael Eckmann.
Scalar Variables Start the file with: #! /usr/bin/perl –w No spaces or newlines before the the #! “#!” is sometimes called a “shebang”. It is a signal.
CS 330 Programming Languages 10 / 11 / 2007 Instructor: Michael Eckmann.
Linux+ Guide to Linux Certification, Second Edition
Loops – While, Do, For Repetition Statements Introduction to Arrays
CS 106 Introduction to Computer Science I 10 / 04 / 2006 Instructor: Michael Eckmann.
Perl Basics A Perl Tutorial NLP Course What is Perl?  Practical Extraction and Report Language  Interpreted Language Optimized for String Manipulation.
Introduction to Perl. How to run perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Your program/script.
CS 330 Programming Languages 10 / 10 / 2006 Instructor: Michael Eckmann.
CS 330 Programming Languages 09 / 30 / 2008 Instructor: Michael Eckmann.
Perl Lecture #1 Scripting Languages Fall Perl Practical Extraction and Report Language -created by Larry Wall -- mid – 1980’s –needed a quick language.
Guide To UNIX Using Linux Third Edition
CS 106 Introduction to Computer Science I 02 / 19 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 09 / 28 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 09 / 11 / 2006 Instructor: Michael Eckmann.
Bash Shell Scripting 10 Second Guide Common environment variables PATH - Sets the search path for any executable command. Similar to the PATH variable.
CIS3931 – Intro to JAVA Lecture Note Set 3 19-May-05.
Practical Extraction & Report Language PERL Joseph Beltran.
Introduction to Perl Practical Extraction and Report Language or Pathologically Eclectic Rubbish Lister or …
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
CS 330 Programming Languages 11 / 21 / 2006 Instructor: Michael Eckmann.
Input, Output, and Processing
Linux+ Guide to Linux Certification, Third Edition
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
Meet Perl, Part 2 Flow of Control and I/O. Perl Statements Lots of different ways to write similar statements –Can make your code look more like natural.
CS 206 Introduction to Computer Science II 09 / 10 / 2009 Instructor: Michael Eckmann.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
CS 330 Programming Languages 10 / 07 / 2008 Instructor: Michael Eckmann.
Introduction to Perl Yupu Liang cbio at MSKCC
CS 330 Programming Languages 11 / 13 / 2008 Instructor: Michael Eckmann.
Perl Language Yize Chen CS354. History Perl was designed by Larry Wall in 1987 as a text processing language Perl has revised several times and becomes.
Perl: Lecture 1 The language. What Perl is Merger of Unix tools – Very popular under UNIX – shell, sed, awk Programming language – C syntax Scripting.
Chapter 10: BASH Shell Scripting Fun with fi. In this chapter … Control structures File descriptors Variables.
CS 330 Programming Languages 09 / 28 / 2006 Instructor: Michael Eckmann.
Introduction to Unix – CS 21
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Introduction to Perl “Practical Extraction and Report Language” “Pathologically Eclectic Rubbish Lister”
CS 330 Programming Languages 10 / 02 / 2007 Instructor: Michael Eckmann.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
Introduction to Perl October 4, 2004 Class Meeting 7 * Notes on Perl by Lenwood Heath, Virginia Tech © 2004.
CPTG286K Programming - Perl Chapter 1: A Stroll Through Perl Instructor: Denny Lin.
CS 106 Introduction to Computer Science I 09 / 26 / 2007 Instructor: Michael Eckmann.
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
CS 106 Introduction to Computer Science I 02 / 01 / 2008 Instructor: Michael Eckmann.
Python Let’s get started!.
Week Four Agenda Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming deadlines.
CS 106 Introduction to Computer Science I 09 / 10 / 2007 Instructor: Michael Eckmann.
Perl for Bioinformatics Part 2 Stuart Brown NYU School of Medicine.
CSI605 perl. Perl Facts Perl = Pathologically Eclectic Rubbish Lister Perl is highly portable across many different platforms and operating systems Perl.
File Handle and conditional Lecture 2. File Handling The Files associated with Perl are often text files: e.g. text1.txt Files need to be “opened for.
CSC 4630 Perl 3 adapted from R. E. Beck. Problem But we worked on it first: Input: Read from a text file named in a command line argument Output: List.
CS 106 Introduction to Computer Science I 01 / 24 / 2007 Instructor: Michael Eckmann.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
CS 330 Programming Languages 09 / 30 / 2008 Instructor: Michael Eckmann.
Linux Administration Working with the BASH Shell.
Introduction to Programming the WWW I CMSC Winter 2004 Lecture 8.
PHP.
The Selection Structure
Presentation transcript:

CS 330 Programming Languages 09 / 25 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS Fall 2008 Today’s Topics Questions/comments? Perl –Practical Extraction and Report Language

Perl Michael Eckmann - Skidmore College - CS Fall 2008 You have two options Get Perl on your own machine. Download Perl (version or higher.)‏ –recommend ActivePerl from ActiveState for Mac OS and Windows –Perl is installed by default under most linuxes AND/OR Use the Linux machines in the new Linux lab.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Perl (developed by Larry Wall and many others) is a language that has as it's ancestors C, sed, AWK and others. Sed is short for stream editor, AWK is named for it's authors (of which K is for Kernighan famous for his work on C.) Sed and AWK are good for pattern matching, editing and reporting on text files. Perl has these capabilities too. Some of Perl's syntax is C-like.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 How it's going to be “taught” in this course. –We're going to dive in and see a lot of stuff so you get a general overview of the language quickly. –We will go in more depth later, on several topics. –I suggest you go through a tutorial with and learn from your peers. –We will not learn all there is to know about Perl.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Resources on the web A Perl tutorial Programming Perl book online If that's not enough, you know how to search the internet. I'll try to post some useful links on our course webpage.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Variables need not be declared, they exist upon first use. If you happen to use a variable before it is assigned a value, then it is 0,“”, or false depending on its use. You can though, if you want to, declare variables with my or our (to be explained later.)‏ You can also do use strict; which provides error checking including disallowing the use of undeclared variables.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 –Scalars (hold a single value) Names start with a $ –Arrays Names start with –Hashes (keyed lists aka associative arrays)‏ Names start with a % –Subroutines Names start with an &

Perl Michael Eckmann - Skidmore College - CS Fall 2008 More about hashes –They consist of pairs of data. The first in each pair is the key and the second is the value. –Values can be returned based on their keys. –We'll see an example in a couple of slides

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Example scalar assignment statements (and declarations) --- can hold strings or numerics (integers and floating point.)‏ $age = 50; $name = “Mike”; Example array assignment statements (and = (100, 98, 43, 87, = (“Jerry Garcia”, “Bobby Weir”, “Phil Lesh”); Example hash assignment statement (and declaration)‏ %course_names = (“CS106” => “Intro to CS 1”, “CS206” => “Intro to CS 2”, “CS330” => “Programming Languages”);

Perl Michael Eckmann - Skidmore College - CS Fall = (“Jerry Garcia”, “Bobby Weir”, “Phil Lesh”); When referring to one element of an array, use $ because each element is a scalar and use the typical square brackets with index. Indices start at 0. e.g. $people[0] would refer to the first element of the array. Oddly, scalars can be assigned from the whole array: ($lead, $rhythm, $bass)

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Note: in hashes, the comma can be used instead of the => which is less readable, but valid syntax. %course_names = (“CS106” => “Intro to CS 1”, “CS206” => “Intro to CS 2”, “CS330” => “Programming Languages”); Also, hashes can be used as lists (ignoring the key / value pair meaning.) The first key is the first element of the list, the first value is the second element in the list, the 2 nd key is the third element, and so on. = %course_names; Here, $course_info[0] contains “CS106” $course_info[1] contains “Intro to CS 1” etc.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 %course_names = (“CS106” => “Intro to CS 1”, “CS206” => “Intro to CS 2”, “CS330” => “Programming Languages”); To get a value out of a hash, you can use its key inside { } e.g. $name = $course_names{“CS330”}; $name would contain the string “Programming Languages”.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Output print “Hello, World!\n”; $output_text = “Hello, World”; print $output_text. “\n”; print “$output_text\n”; #same as above because “” causes interpolation print '$output_text \n'; #would print literally --- not value of var and no new line either print “\$output_text\n”; #would print literally --- b/c \ forces $ to be printed so no var

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Operators For numerics: +, -, *, /, %, ** (exponentiation)‏ For strings:. (concatentation), x (multiplies the string by an integer)‏ e.g. $text = “Hey”; $text = $text x 3; # result is HeyHeyHey

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Assignment operators (more than just the =)‏ Here are some examples *=, +=, ||=, x=, etc... e.g. $text = “Hey”; $text x= 3; # same as if we did $text = $text x 3;

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Conditional operators include:, =, ==, != (for numeric comparison)‏ lt, gt, le, ge, eq, ne (for string comparisons)‏ (numeric compare) --- it is a less than followed by equals followed by a greater than symbol without spaces. cmp (string compare)‏

Perl Michael Eckmann - Skidmore College - CS Fall 2008 These probably don’t need much discussion:, =, ==, != (for numeric comparison)‏ lt, gt, le, ge, eq, ne (for string comparisons)‏ But these two compare operators are interesting: (numeric compare)‏ cmp (string compare)‏ The two compare operators above Return –1 if left operand is less than right operand Return 0 if left operand is equal to right operand Return +1 if left operand is greater than right operand

Perl Michael Eckmann - Skidmore College - CS Fall 2008 We covered: –Printing Interpolation “ “ vs. literal text ' ' \ reference operator within “ “ to force literal –Operators (numeric and string)., x, +, *, etc. –Assignment operators *=,.=, ||=, etc. –conditional operators (numeric and string)‏ Next we'll cover: –true and false –Logical &&, ||, !, and, or, not, xor (words vs. symbols different precedence)‏ –for, while, until, do-while, if, else, elsif –File handling –Assignments (chaining them --- b/c they return lvalues)‏ –chop, chomp –Class exercise –Regular expressions

Perl Michael Eckmann - Skidmore College - CS Fall 2008 True and false –Perl treats any string as true except “0” and “” which are false. –Perl treats any number as true except 0 which is false. Comments –Single line comments are specified starting with the # character and go until a newline.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Logical operators Both symbols and words &&, || ! and, or, not (also allowed but have lower precedence than their related symbols above.)‏ Both forms of AND (&& and and) and OR (|| and or) are short circuit operators. That means that if the left operand determines the outcome of the whole condition, then the right operand is not evaluated.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Short circuiting When using or or ||, if the left operand evaluates to true then the whole thing is true (because true or anything is true) so, the right side is not evaluated. When using and or &&, if the left operand evaluates to false then the whole thing is false (because false and anything is false) so, the right side is not evaluated. E.g. if ($x == 1 && $y < 0) # suppose $x had the value 0, it is unnecessary to evaluate the $y < 0 at all, because the condition will be false regardless.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Short circuiting E.g. if ($z == 0 || $y < 0) # suppose $z had the value 0, it is unnecessary to evaluate the $y < 0 at all, because the condition will be true regardless.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Example of how Perl programmers use this short circuit feature to their advantage to make concise readable code. open(FILEHAND, “<“, $fname) or die “can’t open file.\n”; Because of the short circuit, the above works in the following way, the open function returns false if the file can’t be opened. If that happens the die function is called (see the or operator) which prints the error to STDERR and kills the program. If the file can be opened, then true is returned and the or part is not evaluated (executed.)‏

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Open and die are two of Perl’s built-in functions. STDIN, STDOUT, and STDERR are file handles that are automatically available and open in Perl programs. STDIN is the keyboard and the other 2 are the console. We’ll come back to more about opening files later, let’s instead continue with our discussion of more operators.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 if, elsif, else structures (notice the odd spelling of elsif --- there is no “e” in it.)‏ Why do you think? As expected, the elsif and else portions of the if structure are optional. You can have an if, followed by zero or more elsif’s, followed by zero or one else’s. Also, there’s an unless that can be used instead of the if (but still can use the elsif’s and else portions.)‏ unless reverses the test if you had used if

Perl Michael Eckmann - Skidmore College - CS Fall 2008 if ($count < 10) { # do something here } Is the same as: unless ($count >= 10) { # do something here }

Perl (example of if/elsif/else)‏ Michael Eckmann - Skidmore College - CS Fall 2008 if ($count < 10) { # do something here } elsif ($count >100)‏ { # do something here } else { # do something here }

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Previous slides showed how to use if and unless on blocks of code. Interestingly, if, unless, while, until and foreach can all be used as modifiers to a simple statement. Examples: print “Hello” unless $printing_is_off; $total++ if $increase_total;

Perl Michael Eckmann - Skidmore College - CS Fall 2008 while, until, foreach and for are looping structures in Perl. while and for act as you’d expect from knowing C++ or Java. until executes its loop until the condition becomes true, whereas while executes its loop until the condition becomes false. Yeah it’s redundant. So much of Perl is.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 foreach works on list data (e.g. arrays.)‏ Example: foreach $element { print “$element is a person in the array\n”; } # foreach iterates through all values of the array in the parens and uses the variable just after the word foreach to temporarily store the value. Then the code in the { }’s executes once for every element of the array. Note: $element are user-defined names (not special to Perl)‏

Perl Michael Eckmann - Skidmore College - CS Fall 2008 open( INDATA, “< “, “datafile.txt”) or die “can’t open datafile.txt”; Alternatively, one can combine the mode with the file name in one string: e.g. “<datafile.txt” Modes: < is input, > is output (writing), >> is append, +< is read-write (assumes file exists) and >+ is read-write (file might not exist).

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Another thing to notice about Perl is that for calling the built-in functions we can use parentheses around the arguments or not use the parentheses. e.g. open(FH, “<data.txt”); open FH, “<data.txt”; # both are valid and do the same thing. But be careful with something like: print ( ) * 2; # this will cause the parens to enclose the args # and therefore it would print 10 not 20. We would want this instead: print (( ) * 2);

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Use the angle brackets to read a line from a file handle. Use print to write to a filehandle. e.g. print FH “A line to be written to file\n”;

Perl Michael Eckmann - Skidmore College - CS Fall 2008 When reading lines from STDIN or a file, the line will contain a \n at the end. It is often the case that you wish to get rid of it. Use chomp function to do this. $inline = ; chomp($inline); Or chomp($inline = ); Chomp removes the end of record marker and returns the # of chars removed. chop is also a function. It removes the last character regardless if it is \n or not and returns the character.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 An interesting thing about return values: The assignment operators are interesting in that they return the variable on the LHS of the assignment as an lvalue. An lvalue is something that can have a value assigned to it. This allows chaining of assignments like: $num1 = $num2 = $num3 = 0; # 0 is assigned to num3, then num3 to num2 … And ($temp -= 32) *= 5/9; # the -= in parens returns the $temp as an lvalue which is assigned # a new value with the *= assignment.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Let's go to the Linux lab and do an exercise and some more lecture.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 First, everyone log in, open a terminal window type the following: –mkdir cs330 –cd cs330 Save the input_file_for_perl.txt into your cs330 directory. and bring up a text editor (e.g. either emacs or gedit) by typing in the terminal window: –gedit & –enter this as the first line in your file: #!/usr/bin/perl

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Continue and add this line below the shebang line: print “Hello World\n”; save the file as –helloWorld.pl at the terminal window do the following: chmod 755 helloWorld.pl (makes your script executable)‏./helloWorld.pl (executes your script using shebang line)‏ OR perl helloWorld.pl (executes your script explicitly using perl)

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Let's try the following as an exercise: –read each line of input from the file on the notes page input_file_for_perl.txt until the line that has “eof” is read –store each line in an element of an array (with the exception of the last line “eof”.)‏ –store the array into a hash (can be done with one line of code)‏ –Then, in a loop, ask the user for input (from STDIN) for a product and output its price by looking it up in the hash. Do this until user enters some sentinel that you make him/her aware of at the beginning. Note: the format of the file consists of a product name on one line and its price on the next line, then another product name on the next line and it's price on the next line and so on until the last line of the file which contains the word: eof

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Matching string basics =~ (matches)‏ m/ / (this is the format of match regular expression)‏ Note: you put the regular expression in between the / / The format of a complete expression which will evaluate to true or false depending on whether the string matched or not (anywhere within the string) is as follows: ($some_string =~ m/RegExprToMatch/)‏ Examples: (“CS330 Programming Languages” =~ m/Prog/) # true (“CS330 Programming Languages” =~ m/CS106/) # false

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Matching string basics !~ (doesn't match)‏ Examples: (“CS330 Programming Languages” !~ m/Prog/) # false (“CS330 Programming Languages” !~ m/CS106/) # true You may use any other character as a delimiter other than the /'s if you wish. e.g. m#Prog# could be used instead of m/Prog/ The m for the m/ / matching operator is optional if we use the /'s as the delimiters. To match a / you have two choices, either use a different delimiter, then just put the slash in there, or backslash the slash to make it an escape sequence.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 More information: Variables can be put inside the / / search pattern and they are interpolated. =~ can be omitted if matching the $_ special default variable Metacharacters {}[]()^$.|*+?\ have special meaning inside the m/ /. If you wish to match those characters you need to backslash them. Also, regardless of the delimiter, if you which to match what you used as the delimiter, guess what you need to do? ^ forces the match to be required to be at the very beginning of the string $ forces the match to be required to be at the very end of the string Examples: (“CS330 Programming Languages” =~ m/^Prog/) # false, not at beginning (“CS330 Programming Languages” =~ m/ges$/) # true, ges is at the end (“CS330 Programming Languages” =~ m/^ges$/) # false, ges not the whole string (“CS330” =~ m/^CS330$/) # true, CS330 is the complete string

Perl Michael Eckmann - Skidmore College - CS Fall 2008 More information: Character classes are put between [ ] square brackets within the pattern --- this means any one character in the [ ] is able to match. May use ^ (not) to not match a char inside the character class May use – (hyphen) to specify a range of characters for the class “Hay is for horses” =~ m/[A-Z]ay/; # matches if the string contains any capital letter followed by ay “The boardgame Payday is lame” =~ m/[A-Z]ay/; # this would be true too, it matches Pay “The boardgame Payday is lame” =~ m/[^A-Z]ay/; # this would be true too, why?

Perl Michael Eckmann - Skidmore College - CS Fall 2008 More information: Character classes are put between [ ] square brackets within the pattern --- this means any one character in the [ ] is able to match. May use ^ (not) to not match a char inside the character class May use – (hyphen) to specify a range of characters for the class “Hay is for horses” =~ m/[A-Z]ay/; # matches if the string contains any capital letter followed by ay “The boardgame Payday is lame” =~ m/[A-Z]ay/; # this would be true too, it matches Pay “The boardgame Payday is lame” =~ m/[^A-Z]ay/; # this would be true too, why? It matches day These are special variables that are set for a match: $` $& and $' (left, matched, right)‏ Let's put this code in a program and print out the variable values to see what matches.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 There are ways to specify common character classes \d (any digit)‏ \s (any whitespace \ \t\r\n\f \w (any “word” character (a digit, letter or underscore))‏ \D (any non-digit)‏ \S (any non-whitespace)‏ \W (any non-word character)‏. (any character other than newline \n)‏ These can be used within the square brackets or without.

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Modifiers are characters that go after the second forward slash i is a modifier for ignore case. The behaviour for no modifier (the default) is that. Matches any non-newline character ^ matches at beginning of string $ matches at end of string (or before a newline at end)‏ s modifier: treats the string as a single long line, so. matches any character including newline m modifier: treats string as multiple lines so, ^ and $ match the beginning or end of any line But now, \A matches the beginning of the whole string, \Z matches the end of the whole string. Let’s look at this webpage’s examples under Using Character Classes for some more examples:

Perl Michael Eckmann - Skidmore College - CS Fall 2008 | alternation character (acts sort of like a logical or)‏ Grouping characters using the parentheses Getting the “submatches” by using the $1, $2, $3, etc. variables which are set via the parentheses. Repetitions ? - 0 or 1 time * - 0 or more times or more times { } – min and max, at least or exactly Let’s continue looking at this site for examples:

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Recap on the special variables we learned $_ $` $& and $' (left, match, right)‏ $0 (program name)‏ $1, $2, $3,... (the submatches)‏

Perl Michael Eckmann - Skidmore College - CS Fall 2008 Let’s look at a larger parsing example using many of the features we just learned: The “doing string selections” section of: The following page is a good page for reference. It is a nice summary of the different characters and their meanings with succinct examples: