Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.

Slides:



Advertisements
Similar presentations
Perl Practical Extration and Reporting Language An Introduction by Shwen Ho.
Advertisements

1/12 Steven Leung Very Basic Perl Tricks A Few Ground Rules File I/O and Formatting Operators, Flow Control Statements Regular Expression Subroutines Hash.
ARDUINO CLUB Session 1: C & An Introduction to Linux.
● Perl reference
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
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.
CSET4100 – Fall 2009 Perl Introduction Scalar Data, Operators & Control Blocks Acknowledgements: Slides adapted from NYU Computer Science course on UNIX.
Perl Basics Chapters 1-6 of “Learning Perl” By Randal Schwartz, Tom Christiansen & Larry Wall; ISBN , 302 pages. Second Edition, July 1997.
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 Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
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.
Practical Extraction & Report Language Picture taken from
Getting Started with Perl (and Excel) Biophysics 101 September 17, 2003 Griffin Weber (With material from Jon Radoff and Ivan Ovcharenko)
Operators. Perl has MANY operators. –Covered in Chapter 3 of Prog.Perl Most operators have numeric and string version –remember Perl will convert variable.
I/O while ($line= ){ #remove new line char \n chomp($line); if($line eq “quit”){ exit(1); } while ( ){ #remove new line char \n chomp($_); if($_ eq “quit”){
Lecture 2 BNFO 135 Usman Roshan. Perl variables Scalar –Number –String Examples –$myname = “Roshan”; –$year = 2006;
 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.
Subroutines Just like C, PERL offers the ability to use subroutines for all the same reasons – Code that you will use over and over again – Breaking large.
PHP Overview CS PHP PHP = PHP: Hypertext Preprocessor Server-side scripting language that may be embedded into HTML One goal is to get PHP files.
PHP == ‘ Hypertext Preprocessor ’ Open-source, server-side scripting language Used to generate dynamic web-pages PHP scripts reside between reserved PHP.
Introduction to Perl Thaddeus Aid IT Learning Programme University of Oxford 15/04/2014.
Practical Extraction & Report Language PERL Joseph Beltran.
Introduction to Perl & BioPerl Dr G. P. S. Raghava Bioinformatics Centre Bioinformatics Centre IMTECH, Chandigarh Web:
Chap 3 – PHP Quick Start COMP RL Professor Mattos.
INE1020 Introduction to Internet Engineering Tutorial 9 Lab 6 and Assignment 2.
Perl By Gabe and Ted. History Perl was created by Larry Wall while working at NASA’s Jet Propulsion Labs. Larry Wall also created patch which is in widespread.
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.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
Introduction to Perl Yupu Liang cbio at MSKCC
Books. Perl Perl (Practical Extraction and Report Language) by Larry Wall Perl 1.0 was released to usenet's alt.comp.sources in 1987 Perl 5 was released.
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.
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.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
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.
More Perl Data Types Scalar: it may be a number, a character string, or a reference to another data type. -the sigil $ is used to denote a scalar(or reference)
Introduction to Perl NICOLE VECERE. Background General Purpose Language ◦ Procedural, Functional, and Object-oriented Developed for text manipulation.
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.
Week Five Agenda Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming deadlines.
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.
 History  Ease of use  Portability  Standard  Security & Privacy  User support  Application &Popularity Today  Ten Most Popular Programming Languages.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
PERL By C. Shing ITEC Dept Radford University. Objectives Understand the history Understand constants and variables Understand operators Understand control.
The Scripting Programming Language
PZ02CX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ02CX - Perl Programming Language Design and Implementation.
Dept. of Animal Breeding and Genetics Programming basics & introduction to PERL Mats Pettersson.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
CS 360 Internet Programming. Objectives for this class period Web programming is important Administrative organization of the course Introduction to first.
Operators. Perl has MANY operators. –Covered in Chapter 3 of Camel –perldoc perlop Many operators have numeric and string version –remember Perl will.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Linux Administration Working with the BASH Shell.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
1 Lecture 8 Shell Programming – Control Constructs COP 3353 Introduction to UNIX.
Information and Computer Sciences University of Hawaii, Manoa
Perl Programming Language Design and Implementation (4th Edition)
DBW - PHP DBW2017.
Control Structures: for & while Loops
Lesson 2. Control structures File IO - reading and writing Subroutines
Basics.
The Selection Structure
Presentation transcript:

Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008

The Department of Electrical and Computer Engineering 2 Outline What is Perl Variables Operators Flow Control –Conditions Subroutines File Handling IO System Calls Regular Expressions

The Department of Electrical and Computer Engineering 3 What is Perl Scripting language developed in C –Does not compile –Is run by an interpreter #!/bin/perl Useful for processing text files Can be embedded to C/C++

The Department of Electrical and Computer Engineering 4 Variables Scope –Global (our) –Local (my) Type –Scalar $ –Hash % Predefined –$^O –$_ –$!

The Department of Electrical and Computer Engineering 5 Operators Addition (+) Subtraction (–) Multiplication (*) Division (/) Power (**) Modulus (%) Increment/Decrement (++/--) String Concatenation (.)

The Department of Electrical and Computer Engineering 6 Flow Control If, Elsif, Else While –while( ) Do-While –do{ … } while( ); For –for(my $i = 0; $i < 10; ++$i) Foreach –foreach my $var unless or die

The Department of Electrical and Computer Engineering 7 Conditions Numerical –Equal == | Not equal != –Greater > | Greater or equal >= –Less < | Less or equal < String –Equal eq –Not equal ne Complex conditions –and (all conditions must be true) –or (at least one condition must be true) –not (negates an expression)

The Department of Electrical and Computer Engineering 8 Sub Routines Small blocks of code that perform an action. –Factorial –Absolute Value Are user defined –May return a value Syntax –sub (){ Code –} –Parameters are passed my $firstarg = or shift() –Value is returned using return statement return 0

The Department of Electrical and Computer Engineering 9 File Handling Reading and writing is done sequentially using file handles. open(, “ ”) $var = while( ){ –chomp($_) –$_ } close( )

The Department of Electrical and Computer Engineering 10 IO Reading from the standard input –$number = ; Writing to the standard output –print “ ”; print “$variable”; #displays the value of $variable print ‘$variable’; #displays the word $variable Reading from file handle DATA –$number = ; Writing to file handle DATA –print DATA “ ”; –print <<DATA; Any string –DATA

The Department of Electrical and Computer Engineering 11 System Calls mkdir rmdir chdir rename system exec Shell Commands open(FILE, “ls |”);

The Department of Electrical and Computer Engineering 12 Regular Expressions Search a string for a given pattern $var =~ /hello/; is true if $var contains the string hello $num =~ /([0-9]*)(.*)/ –$1 contains a string full of numbers –$2 contains the string after the first pattern of numbers $str =~ s/hello(.*)/$1/; –Replaces the string in the first // for the one in the second // if($_ =~ /$name/i) searches for a the value inside of $name in $_ ignoring the case

The Department of Electrical and Computer Engineering 13 Regular Expressions Characters that must be escaped –/ –. –$ –% –\ –*

The Department of Electrical and Computer Engineering 14 Questions?