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.

Slides:



Advertisements
Similar presentations
Programming and Perl for Bioinformatics Part III.
Advertisements

CS 497C – Introduction to UNIX Lecture 31: - Filters Using Regular Expressions – grep and sed Chin-Chih Chang
Practical Extraction & Report Language Picture taken from
Regular Expressions Regular Expression (or pattern) in Perl – is a template that either matches or doesn’t match a given string. if( $str =~ /hello/){
CS 330 Programming Languages 09 / 30 / 2008 Instructor: Michael Eckmann.
Using regular expressions Search for a single occurrence of a specific string. Search for all occurrences of a string. Approximate string matching.
Objected Oriented Perl An introduction – because I don’t have the time or patience for an in- depth OOP lecture series…
Scripting Languages Chapter 8 More About Regular Expressions.
CSE S. Tanimoto Perl Arrays, Functions, Lists, Refs, Etc 1 Perl: Arrays, Functions, References, Etc. Arrays Slices, splices Contexts: list, scalar.
Basic Perl Programming
Lecture 7: Perl pattern handling features. Pattern Matching Recall =~ is the pattern matching operator A first simple match example print “An methionine.
Pattern matching with regular expressions A common file processing requirement is to match strings within the file to a standard form, e.g. address.
Lecture 8 perl pattern matching features
Perl. Perl notes 2 Perl Perl - Practical extraction report language –for text files –system management –combines C, SED, AWK, SH –interpreted –dynamic.
Perl Refernces. Kinds of references: hard: a scalar variable that points to data symbolic: a variable that names another reference typeglob: a kind of.
Regular Expressions Regular expressions are a language for string patterns. RegEx is integral to many programming languages:  Perl  Python  Javascript.
Perl Practical(?)‏ Extraction and Report Language.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Regular Expression in Java 101 COMP204 Source: Sun tutorial, …
Programming in Perl regular expressions and m,s operators Peter Verhás January 2002.
CS 330 Programming Languages 10 / 07 / 2008 Instructor: Michael Eckmann.
Perl: Lecture 2 Advanced RE & CGI. Regular Expressions 2.
Regular Expressions – An Overview Regular expressions are a way to describe a set of strings based on common characteristics shared by each string in.
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.
CPTG286K Programming - Perl Chapter 7: Regular Expressions.
Overview A regular expression defines a search pattern for strings. Regular expressions can be used to search, edit and manipulate text. The pattern defined.
Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Introduction to Regular Expression for sed & awk by Susan Lukose.
Regular Expressions for PHP Adding magic to your programming. Geoffrey Dunn
Regular Expressions in Perl CS/BIO 271 – Introduction to Bioinformatics.
Introduction to Unix – CS 21
CS346 Regular Expressions1 Pattern Matching Regular Expression.
Data Structures: Arrays Damian Gordon. Arrays Imagine we had to record the age of everyone in the class, we could do it declaring a variable for each.
Introduction to sed. Sed : a “S tream ED itor ” What is Sed ?  A “non-interactive” text editor that is called from the unix command line.  Input text.
CS 330 Programming Languages 10 / 02 / 2007 Instructor: Michael Eckmann.
CS 330 Class 9 Programming plan for today: More of how data gets into a script Via environment variables Via the url From a form By editing the url directly.
Institute for Visualization and Perception Research 1 © Copyright 1998 Haim Levkowitz Perl primer... Syntax similar to C, various shell script langs. 3.
Perl Chapter 6 Functions. Subprograms In Perl, all subprograms are functions – returns 0 or 1 value – although may have “side-effects” optional function.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong. Adminstrivia Homework 4 not yet graded …
Digital Text and Data Processing Tokenisation. Today’s class □ Tokenisation and creation of frequency lists □ Keyword in context lists □ Moretti and distant.
1 DIG 3563: Lecture 2a: Regular Expressions Michael Moshell University of Central Florida Information Management.
Introduction to Perl NICOLE VECERE. Background General Purpose Language ◦ Procedural, Functional, and Object-oriented Developed for text manipulation.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
Basic Variables & Operators Web Programming1. Review: Perl Basics Syntax ► Comments: start with # (ignored by Perl) ► Statements: ends with ; (performed.
Unit 11 –Reglar Expressions Instructor: Brent Presley.
Introduction to Programming the WWW I CMSC Winter 2004 Lecture 13.
Michael Kovalchik CS 265, Fall  Parenthesis group parts of expressions together  “/CS265|CS270/” => “/CS(265|270)/”  Groups can be nested  “/Perl|Pearl/”
Interpolation Variable Interpolation, Backslash Interpolation.
Department of Electronic & Electrical Engineering IO reading and writing variables scanf printf format strings "%d %c %f"
Chapter 4 © 2009 by Addison Wesley Longman, Inc Pattern Matching - JavaScript provides two ways to do pattern matching: 1. Using RegExp objects.
Programming Perl in UNIX Course Number : CIT 370 Week 2 Prof. Daniel Chen.
Dept. of Animal Breeding and Genetics Programming basics & introduction to PERL Mats Pettersson.
Pattern Matching: Simple Patterns. Introduction Programmers often need to scan a file, directory, etc. for a specific substring. –Find all files that.
CS 330 Programming Languages 09 / 30 / 2008 Instructor: Michael Eckmann.
CS 368 – Intro to Scripting Languages Summer 2009 Cartwright, De Smet, LeRoy 1 Day 6: References suggested reading: perlreftut
Chapter 18 The HTML Tag
CSE 341 S. Tanimoto Perl Perl: User Defined Functions sub funny_print { my ($name, $age) print
SNOBOL StriNg Oriented SymBOlic Language
Introduction to Perl: Part II
Regular Expressions ICCM 2017
System Administration Introduction to Scripting, Perl Session 5 – Fri 23 Nov 2007 References: Perl man pages Albert Lingelbach, Jr.
Perl Programming Language Design and Implementation (4th Edition)
Perl: Functions, References, Etc.
Functions, Regular expressions and Events
- Regular expressions:
Regular Expression in Java 101
Regular Expression: Pattern Matching
Perl Regular Expressions – Part 1
Presentation transcript:

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