An Introduction to Perl – Part I

Slides:



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

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.
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
Programming Perls* Objective: To introduce students to the perl language. –Perl is a language for getting your job done. –Making Easy Things Easy & Hard.
CSET4100 – Fall 2009 Perl Introduction Scalar Data, Operators & Control Blocks Acknowledgements: Slides adapted from NYU Computer Science course on UNIX.
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.
Introduction to Perl Learning Objectives: 1. To introduce the features provided by Perl 2. To learn the basic Syntax & simple Input/Output control in Perl.
LING 388: Language and Computers Sandiway Fong Lecture 3: 8/28.
Perl Lecture #1 Scripting Languages Fall Perl Practical Extraction and Report Language -created by Larry Wall -- mid – 1980’s –needed a quick language.
Operators. Perl has MANY operators. –Covered in Chapter 3 of Prog.Perl Most operators have numeric and string version –remember Perl will convert variable.
Introduction to Perl Software Tools. Slide 2 Introduction to Perl l Perl is a scripting language that makes manipulation of text, files, and processes.
CS 898N – Advanced World Wide Web Technologies Lecture 7: PERL Chin-Chih Chang
Number systems Converting numbers between binary, octal, decimal, hexadecimal (the easy way)
Practical Extraction & Report Language PERL Joseph Beltran.
1 Perl Perl basics Perl Elements Arrays and Hashes Control statements Operators OOP in Perl.
2440: 211 Interactive Web Programming Expressions & Operators.
Print 'Hello world.'; Tren Griffith. Outline:  Perl introduction  Scalar Data  Variables  Operators  Control Structures  Input  Lists and Arrays.
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.
Perl Practical(?)‏ Extraction and Report Language.
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.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
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.
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.
Basic Variables & Operators Web Programming1. Review: Perl Basics Syntax ► Comments: start with # (ignored by Perl) ► Statements: ends with ; (performed.
Perl Variables: Array Web Programming1. Review: Perl Variables Scalar ► e.g. $var1 = “Mary”; $var2= 1; ► holds number, character, string Array ► e.g.
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.
PERL By C. Shing ITEC Dept Radford University. Objectives Understand the history Understand constants and variables Understand operators Understand control.
ITM © Port, KazmanVariables - 1 ITM 352 Data types, Variables Class #4.
Operators. Perl has MANY operators. –Covered in Chapter 3 of Camel –perldoc perlop Many operators have numeric and string version –remember Perl will.
Chapter 16 Introduction to Perl Perl (Practical Extraction and Report Language) Developed by Larry Wall as a Unix scripting language. Popular server-side.
Input, Output and Variables GCSE Computer Science – Python.
© 2010 Robert K. Moniot1 Chapter 6 Introduction to JavaScript.
PHP using MySQL Database for Web Development (part II)
Chapter 2 Basic Computation
ITM 352 Data types, Variables
Overview: Programming Concepts
CSE 102 Introduction to Computer Engineering
Variables, Expressions, and IO
PHP Introduction.
A290 TOOLS IN COMPUTING: JAVASCRIPT
Chapter 2 Basic Computation
Perl for Bioinformatics
Statements, Comments & Simple Arithmetic
Programming in Perl Introduction
Perl Variables: Array Web Programming.
Control Structures: if Conditional
Lecture 2 Python Programming & Data Types
An Introduction to Perl
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.
PHP.
Digital Electronics and Microprocessors
Lecture 2 Python Programming & Data Types
Introducing JavaScript
PHP an introduction.
The Selection Structure
CSC 352– Unix Programming, Fall 2012
Introduction to Perl Learning Objectives:
Perl Control Flow Learning Objectives:
DATA TYPES AND OPERATIONS
Introduction to PHP.
Number systems Converting numbers between binary, octal, decimal, hexadecimal (the easy way)
INTRODUCTION to PERL PART 1.
Karan Thaker CS 265 Section 001
Python Creating a calculator.
Presentation transcript:

An Introduction to Perl – Part I Emily Goldberg Perl, a compact Unix-type scripting language created in the 1980’s, is an easy to write language with multiple uses. The primary uses of Perl are administrative tasks and server-side scripting for web pages.

Scalar Data Scalar – holds one piece of data Numbers: Floating-Point Integer Non-decimal 3.11023 -12 0377 octal -2.7e32 3_814_524_705 0xff hex 0b11111111 binary The basic unit of data is scalar data. Scalars can be numbers or strings. If a box is a container that holds one pair of shoes, then a crate is a container that holds multiple boxes. Similarly, scalar data (i.e.- strings, integers) hold one piece of data as opposed to a list which is a collection of scalars.

Scalar Data (cont’d.) Strings: Single-Quoted Double-Quoted 'hello\nthere' hello\nthere “hello\nthere” hello there $string="world"; print "hi $string \n!"; hi world !

Variables Use $ prefix to denote a variable Ex.- $_points=5; $name2=‘Larry’; Variable names can contain letters, numbers, and underscores, but may NOT begin with a number.

Operators Number Operators Operation Operator Example Add + Subtract - Multiply * Divide / Modulus % 10.5%3.2 = 1 Exponentiation ** 2**3 = 8 Assign =, *=. += Comparison ==, !=, <,>,<=,>=

Operators (cont’d.) String Operators Operation Operator Example Concatenation . "hello"."world" helloworld Repetition x “hello”x3 hellohellohello Comparison eq, ne, lt, gt, le, ge Assignment =, *=. +=, .= $name2.=‘ Lee’ larry Lee

Automatic Conversion Operations Results "hello“ . 3 * 5 “hello15" “12” * “3” 36 "12fred34" * " 3" 12 - ”fred” 12

Standard Input/Output Ex. - print "The answer is ", 6 * 7, ".\n"; Input Ex. - $line=<STDIN>; Remove “\n”- chomp($line);

Control Structures: if-else if ($language eq “Perl”) { print “Always use curly braces!” ;} else { print “ Who knows?!”;}

Control Structures: while while(defined($line=<STDIN>)) {chomp($line); print “This line was: $line \n”; } while(<>) { chomp; print “This line was: $_ \n”; }

Lists and Arrays A list is an ordered collection of scalars. An array is a variable that contains a list. A list with five elements

Lists and Arrays(cont’d.) @numbers=(1,2,3,4); @numbers=(1..4); numbers[0]=‘one’; print $numbers[$#numbers]; $a=pop( @numbers); push( @numbers, $a+3);

Questions?

Refrences Learning Perl by Randal Schwartz and Tom Phoenix (Via Drexel Library electronic resources) “Perl Basics” (http://www.cs.drexel.edu/~knowak/cs265_fall_2009/perl_basics.pdf)