Introduction to Perl William G. Dishman CUR/516 November 5, 2014.

Slides:



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

The Linux Operating System Lecture 6: Perl for the Systems Administrator Tonga Institute of Higher Education.
● Perl reference
CSC 4630 Perl 1. Perl Practical Extraction and Support Language A glue language under UNIX Written by Larry Wall Claimed to be the most portable of scripting.
Programming Perls* Objective: To introduce students to the perl language. –Perl is a language for getting your job done. –Making Easy Things Easy & Hard.
Introduction to Perl Bioinformatics. What is Perl? Practical Extraction and Report Language A scripting language Components an interpreter scripts: text.
Perl Basics Chapters 1-6 of “Learning Perl” By Randal Schwartz, Tom Christiansen & Larry Wall; ISBN , 302 pages. Second Edition, July 1997.
CS311 – Today's class Perl – Practical Extraction Report Language. Assignment 2 discussion Lecture 071CS Operating Systems I.
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.
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)
Scripting Languages. Originally, a script was a file containing a sequence of commands that needed to be executed Control structures were added to make.
Perl Lecture #1 Scripting Languages Fall Perl Practical Extraction and Report Language -created by Larry Wall -- mid – 1980’s –needed a quick language.
PHPPHP What is PHP? Hypertext Pre-processor (PHPs) is a server- side scripting language In early versions, PHP stand for Personal Home Page. server-side.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
Python  By: Ben Blake, Andrew Dzambo, Paul Flanagan.
Introduction to Perl Part I By: Cédric Notredame (Adapted from BT McInnes)
PHP. Why should we learn web programming? No need write socket programming. - You can forget TCP/IP & OSI layers. - Web server handles socket tasks for.
Practical Extraction & Report Language PERL Joseph Beltran.
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
INTERNET APPLICATION DEVELOPMENT For More visit:
Introduction to Perl Practical Extraction and Report Language or Pathologically Eclectic Rubbish Lister or …
Introduction to Perl & BioPerl Dr G. P. S. Raghava Bioinformatics Centre Bioinformatics Centre IMTECH, Chandigarh Web:
Nael Alian Introduction to PHP
Introduction to programming in Perl. What is Perl ? Perl : Practical Extraction and Report Language by Larry Wall in 1987 Text-processing language Glue.
CS 105 Perl: Course Introduction Nathan Clement 13 May 2014.
Perl Michael U. Ang. History of Perl Perl was introduced in 1987 reason for its creation was that Mr. Wall was unhappy by the functionality that sed,
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl.
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.
PHP and JavaScript Nov. 26, 2013 Kyung Eun Park Computer and Creativity (COSC109) Towson University.
Perl Practical(?)‏ Extraction and Report Language.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
PHP. What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Sed, awk, & perl CS 2204 Class meeting 13 *Notes by Mir Farooq Ali and other members of the CS faculty at Virginia Tech. Copyright 2003.
Introduction to Perl Yupu Liang cbio at MSKCC
Introduction to Web Programming. Introduction to PHP What is PHP? What is a PHP File? What is MySQL? Why PHP? Where to Start?
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 Ronald L. Ramos Proglan. What is PERL? Perl stands for Practical Extraction and Reporting Language. (or Pathologically Eclectic Rubbish Lister).
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Introduction to PHP.
Introducing System Managers to Win32 Perl Programming Tim Christian College of Arts and Sciences Computing Support Services.
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.
IT ELECTIVE 2.  Web server Can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that.
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.
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.
Perl Lab #11 Intro to Perl Debbie Bartlett. Perl Lab #1 2 Perl Practical Extraction and Report Language –or- Pathologically Eclectic Rubbish Lister Created.
1 PHP Intro PHP Introduction After this lecture, you should be able to: Know the fundamental concepts of Web Scripting Languages in general, PHP in particular.
PERL By C. Shing ITEC Dept Radford University. Objectives Understand the history Understand constants and variables Understand operators Understand control.
CSI605 perl. Perl Facts Perl = Pathologically Eclectic Rubbish Lister Perl is highly portable across many different platforms and operating systems Perl.
The Scripting Programming Language
Dept. of Animal Breeding and Genetics Programming basics & introduction to PERL Mats Pettersson.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
PHP stands for …….. “PHP Hypertext Pre-processor” and is a server-side scripting language like ASP. PHP scripts are executed on the server PHP supports.
The full name of PERL is Practical extraction and report language. It is similar to shell script and lot easier & powerful language. Perl is free to download.
PHP using MySQL Database for Web Development (part II)
PERL.
PERL.
Perl Programming Language Design and Implementation (4th Edition)
An Introduction to Perl – Part I
PHP Introduction.
Control Structures: for & while Loops
Programming Perls* Objective: To introduce students to the perl language. Perl is a language for getting your job done. Making Easy Things Easy & Hard.
Web Programming Language
Introduction to PHP.
INTRODUCTION to PERL PART 1.
Karan Thaker CS 265 Section 001
Presentation transcript:

Introduction to Perl William G. Dishman CUR/516 November 5, 2014

Brief Introduction Perl was developed by Larry Walls, because the available scripting languages didn’t have the ability to manipulate text that he required. Because his area of study was in languages, he developed Perl to be context-based just like natural human languages. It is so versatile and flexible that it is called the “Swiss army knife” of scripting languages.

Brief Introduction It is part of the LAMP solution for web servers L– Linux (free operating system) A – Apache (free webserver) M– MySQL (free database server) P– Perl, Python, PHP (scripting languages)

Brief Introduction Perl is not an acronym. It was actually named after the “Pearl of great value” from a parable in the Bible. Perl can be called a backronym, since the expansions came after it got its name. “Practical Extraction and Report Language” “Pathologically Eclectic Rubbish Lister”

Perl Installation Linux- Perl comes with UNIX/Linux Windows- Download ActivePerl from the following website: Modules can be downloaded from CPAN (Comprehensive Perl Archive Network)

Programming Tips Add code a few lines at a time. Test frequently. Test ideas in a smaller script before adding to your larger script. Should you have problems with your script, review that code that you added, or go back to previously saved version. Indent blocks of code Add comments to your code.

Programming Tips View script created for work.

Hello World # Hello World for Windows # hello_world.pl print “Hello World\n”; Windows Example

Hello World #!/usr/bin/perl # Hello World for Linux/UNIX # hello_world.pl Print “Hello World\n”; Linux Example

Variable Types Scalar $NAME=“Sam”; $NUMBER=1; @ANIMALS=(qw<monkey dog cat>);

Input/Output Input $VARIABLE= Output print “$VARIABLE\n”;

Input/Output File Input open (INFILE, “students.txt”); $STUDENT1= ; chomp($STUDENT1); $STUDENT2= ) chomp($STUDENT2); print “$STUDENT1\n”; print “$STUDENT2\n”; close INFILE;

Input/Output File Input open (INFILE, ; print “$STUDENT[0]\n”; print “$STUDENT[1]\n”; close INFILE;

Input/Output File Output – Creates a fresh file open(OUTFILE, “> students.txt”) print OUTFILE “Mickey Mouse\n”; close OUTFILE;

Input/Output File Output – Adds lines to a file open(OUTFILE, “>> students.txt”) print OUTFILE “Donald Duck\n”; close OUTFILE;

Arithmetic Operators Addition $ANSWER=$NUMBER1+$NUMBER2; $ANSWER=+$NUMBER; Subtraction $ANSWER=$NUMBER1-$NUMBER2; $ANSWER=-$NUMBER; Multiplication $ANSWER=$NUMBER1*$NUMBER2; $ANSWER=*$NUMBER; Division $ANSWER=$NUMBER1/$NUMBER2; $ANSWER=/$NUMBER; Increment $ANSWER++; Decrement $ANSWER--;

String Operations Adding strings together $STRING=“Jack and Jill”.“ went up the hill.”; $FULLNAME=$FIRSTNAME.“ ”.$LASTNAME; Split ($FIRSTNAME,$LASTNAME)=split(/ /,$FULLNAME); Join $FULLNAME=join(/”, “/,$LASTNAME,$FIRSTNAME); Substring $STRING1=substr($STRING2,$initial_position,$length); Index $location=substr($FULLNAME, “,”);

Numeric Logic Operators Equal $NUMBER1 == $NUMBER2 Greater than $NUMBER1 > $NUMBER2 Greater than or equal to $NUMBER1 >= $NUMBER2 Less than $NUMBER1 < $NUMBER2 Less than or equal to $NUMBER1 <= $NUMBER2

String Logic Operators Equal to $STRING1 eq $STRING2 Greater than $STRING1 gt $STRING2 Less than $STRING1 lt $STRING2 Contains $STRING1 =~ $STRING2

Flow Control If Statement if ($NUMBER1 > $NUMBER2){ print “It’s true.\n”; } If-else Statement if ($NUMBER1 > $NUMBER2){ print “$NUMBER1 is greater than $NUMBER2.\n”; } else { print “$NUMBER1 is less than or equal to $NUMBER2.\n”; } If-elsif Statement if ($NUMBER1 > $NUMBER2){ print “$NUMBER1 is greater than $NUMBER2.\n”; }elsif ($NUMBER1 < $NUMBER2){ print “$NUMBER1 is less than $NUMBER2.\n”; }

Flow Control Foreach Loop foreach print “$rock\n”; } foreach $i (1..10){ print “$i \n”; }

Flow Control While Loop $NUMBER=1; While ($NUMBER < 5){ print “$NUMBER \n”; $NUMBER++; }

Flow Control Do-While Loop $NUMBER=1; do{ print “$NUMBER \n”; $NUMBER++; while ($NUMBER < 5)

Using a Loop for File Input open (INFILE, “students.txt”); while ($LINE= ){ chomp($LINE); print “$LINE\n”; } close INFILE;

Flow Control Subroutines &sub1; sub2(); sub sub1 { print “This is sub1.\n”; } sub sub2 { print “This is sub2.\n”; }

Reference Schwartz, R. L., Phoenix, T., & Foy, B. D. (2009). Learning Perl (5th ed.). Sebastopol, CA: O'Reilly. YouTube. (2011, June 13). Larry Wall: Why Perl Is Like a Human Language. Retrieved from