Programming Perl in UNIX Course Number : CIT 370 Week 2 Prof. Daniel Chen.

Slides:



Advertisements
Similar presentations
Chapter 25 Perl and CGI (Common Gateway Interface)
Advertisements

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Introduction to Ruby.
Arrays A list is an ordered collection of scalars. An array is a variable that holds a list. Arrays have a minimum size of 0 and a very large maximum size.
Course A201: Introduction to Programming 10/28/2010.
Chapter 6 Lists and Dictionaries CSC1310 Fall 2009.
Dynamic Arrays Lecture 4. Arrays In many languages the size of the array is fixed however in perl an array is considered to be dynamic: its size can be.
Perl Arrays and Lists Software Tools. Slide 2 Lists l A list is an ordered collection of scalar data. l A list begins and ends with parentheses, with.
Programming Perls* Objective: To introduce students to the perl language. –Perl is a language for getting your job done. –Making Easy Things Easy & Hard.
7 Searching and Regular Expressions (Regex) Mauro Jaskelioff.
Perl Arrays and Lists Learning Objectives: 1. To understand the format and the declaration of Arrays & Lists in Perl 2. To distinguish the difference between.
CS 330 Programming Languages 10 / 14 / 2008 Instructor: Michael Eckmann.
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
CS 330 Programming Languages 10 / 11 / 2007 Instructor: Michael Eckmann.
for($i=0; $i/)
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 898N – Advanced World Wide Web Technologies Lecture 7: PERL Chin-Chih Chang
Perl File I/O and Arrays. File I/O Perl allows to open a file to read, write, or append As well as pipe input or output to another program. —We get to.
Guide To UNIX Using Linux Third Edition
UNIX Filters.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
Computer Programming for Biologists Class 2 Oct 31 st, 2014 Karsten Hokamp
Programming Perl in UNIX Course Number : CIT 370 Week 4 Prof. Daniel Chen.
Computer Programming for Biologists Class 5 Nov 20 st, 2014 Karsten Hokamp
Lecture 8 perl pattern matching features
CPTG286K Programming - Perl Chapter 3: Arrays and List Data.
– Introduction to Perl 10/20/ Introduction to Perl - Lists and Arrays Introduction to Perl Session 3 · lists and arrays.
– Introduction to Perl 10/25/ Introduction to Perl - Recipes and Idioms Introduction to Perl Session 8 · recipes and.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Introduction to Perl Giorgos Georgakilas Graduated from C.E.I.D.Graduated from C.E.I.D. M.Sc. degree in ITMBM.Sc. degree in ITMB Ph.D. student in DIANA-LabPh.D.
Chapter 9: Perl Programming Practical Extraction and Report Language Some materials are taken from Sams Teach Yourself Perl 5 in 21 Days, Second Edition.
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Computer Programming for Biologists Class 3 Nov 13 th, 2014 Karsten Hokamp
Introduction to Programming the WWW I CMSC Winter 2003.
Introduction to Perl “Practical Extraction and Report Language” “Pathologically Eclectic Rubbish Lister”
Programming Perl in UNIX Course Number : CIT 370 Week 6 Prof. Daniel Chen.
Perl Chapter 5 Hashes. Outside of world of Perl, know as associative arrays Also called hash tables Perl one of few languages that has hashes built-in.
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.
Topic 4:Subroutines CSE2395/CSE3395 Perl Programming Learning Perl 3rd edition chapter 4, pages 56-72, Programming Perl 3rd edition pages 80-83,
Perl COEN 351  Thomas Schwarz, S.J Perl Scripting Language Developed by Larry Wall 1987 to speed up system administration tasks. Design principles.
Introduction to Perl October 4, 2004 Class Meeting 7 * Notes on Perl by Lenwood Heath, Virginia Tech © 2004.
CPTG286K Programming - Perl Chapter 5 & 6: Hashes & Basic I/O.
A Few More Functions. One more quoting operator qw// Takes a space separated sequence of words, and returns a list of single-quoted words. –no interpolation.
Programming Perl in UNIX Course Number : CIT 370 Week 3 Prof. Daniel Chen.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
Perl Variables: Array Web Programming1. Review: Perl Variables Scalar ► e.g. $var1 = “Mary”; $var2= 1; ► holds number, character, string Array ► e.g.
Perl Scripting III Arrays and Hashes (Also known as Data Structures) Ed Lee & Suzi Lewis Genome Informatics.
Session 2: PHP Language Basics iNET Academy Open Source Web Development.
BINF 634 Fall LECTURE061 Outline Lab 1 (Quiz 3) Solution Program 2 Scoping Algorithm efficiency Sorting Hashes Review for midterm Quiz 4 Outline.
Arrays and Lists. What is an Array? Arrays are linear data structures whose elements are referenced with subscripts. Just about all programming languages.
CSC 4630 Perl 2 adapted from R. E. Beck. I/O and Arithmetic Form pairs of programmer/investigator/discover Exercise 1. Write a program that prompts the.
Dept. of Animal Breeding and Genetics Programming basics & introduction to PERL Mats Pettersson.
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.
Pattern Matching: Simple Patterns. Introduction Programmers often need to scan a file, directory, etc. for a specific substring. –Find all files that.
CSC 352– Unix Programming, Fall 2011 November 8, 2011, Week 11, a useful subset of regular expressions, grep and sed, parts of Chapter 11.
CMSC330 More Ruby. Last lecture Scripting languages Ruby language –Implicit variable declarations –Many control statements –Classes & objects –Strings.
Chapter 5 Murach's JavaScript and jQuery, C1© 2012, Mike Murach & Associates, Inc.Slide 1.
Introduction to Programming the WWW I CMSC Winter 2004 Lecture 8.
Chapter 17 Arrays Perl to denote an array, for = (10, 20, 30, 50); Array subscripts are number from 0. Array elements require scalar.
IT441 Network Services Administration
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong.
Perl Variables: Array Web Programming.
Control Structures: if Conditional
An Introduction to Perl
Programming Perls* Objective: To introduce students to the perl language. Perl is a language for getting your job done. Making Easy Things Easy & Hard.
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong.
Presentation transcript:

Programming Perl in UNIX Course Number : CIT 370 Week 2 Prof. Daniel Chen

Introduction n Review and Overviews n Chapter 4 n Summary n Lab n Quiz 1 n Next Week (Week 3)

Topics of Discussion n About Perl Variables n Scalars, Arrays, and Hashes n Reading from STDIN n Array Functions n Hash (Associative Array) Functions n More Hashes

Chapter 4: What’s in a Name n 4.1 About Perl Variables n 4.2 Scalars, Arrays, and Hashes n 4.3 Reading from STDIN n 4.4 Array Functions n 4.5 Hash (Associative Array) Functions n 4.6 More Hashes

4.1 About Perl variables n Types u Scalar, Array, Hashes n Scope and the Package u Package, Global Variables n Naming Conventions u Case Sensitive n Assignment Statements n Quoting Rules u Single quotes u Double Quotes u Back Quotes u Perl’s Alternative Quotes (Table 4.1)

4.2 Scalars, Arrays, and Hashes n Scalar Variables u Assignment u The undef Function n Arrays u Special Scalars and Array Assignment u Accessing Elements u Array Slices u Multi-dimension Arrays – Lists of Lists n Hashes u Accessing Elements u Hash Slices u Hashes of Hashes u Array of Hashes

4.3 Reading From STDIN n Assigning Input to a Scalar Variable n The chop and chomp Functions n The read Function n The getc Function n Assigning Input to an Array n Assigning Input to a Hash

4.4 Array Functions n The chop and chomp Functions (with Lists) n The exists Function n The delete Function n The grep Function n The join Function n The map Function n The pack and unpack Functions n The pop Function

Array Functions n The push Function n The shift Function n The delete Function n The splice Function n The split Function n The sort Function n The reverse Functions n The unshift Function

4.5 Hash (Associative Array) Functions n The keys Function n The values Function n The each Function n The delete Function n The exists Function

4. 6 More Hashes n Loading a Hash from a File n Special Hashes u The %ENV hash u The %SIG Hash u The %INC Hash n Context

Matching a string or character at the beginning of a line with a ^ n using the ^ allows you to match words or characters at the beginning of the line only. n Two examples - ls -l ^d - ^…4XC….

Matching a string or character at the end of a line with a $ n The $ lets us match a string or character at the end of the line n Two examples - trouble$ - jet01$

Matching a single or string or character with * n The * allows us to match repeatedly any number of occurrences of any character or string n Two examples - compu*t (computer, computing, compuuuuuute) * ( , 10133, )

Escaping the meaning of a special character with \ n Special characters ($. “ * [ ] | () \ + ?) n To disable the special character - Using \. - Using \*\.pas (*.pas)

Matching ranges or sets using [] n To match certain specific characters or range of characters use [] n Examples - [0-9] or [a-z] - [A-Za-z] - [A-Za-z0-9] - s[a-zA-Z]t - [Cc]omputer - [^a-zA-Z]

Matching a specific number of occurrences with \{\} n If you want to match only a certain number of occurrences, you can use \{ \} n pattern \{n\} (match n occurrences of the pattern) n pattern \[n,\} (match at least n occurrences of the pattern) n pattern \{n,m\} (match occurrences of the pattern between n and m, where n and m are integer numbers between 0 and 255) n Examples - A\{2\}B (AAB) - A\{4,\}B (AAAAAB) - A\{2,4\}B (2 As or 4As)

Summary n Perl Variables n Scalars, Arrays, and Hashes n Reading from STDIN n Array Functions n Hash Functions n Special Characters

Lab n Examples 4.1 – 4.59 (P 43 – 97) n Homework 2

Quiz 1 n Quiz Date: Next Week n Quiz Time: 11:00 AM - 11:30 AM n Contents: Chapter 1- Chapter 4 n No book, no note, no computer

Next Week n Reading assignment (Textbook chapters 5 and 6)