Programming with Perl CSCE 330 Group presentation by: Robert Shannon Robert Shannon Ryan Mullaney Ryan Mullaney Anthony So Anthony So.

Slides:



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

CSE 105 Structured Programming Language (C)
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Ruby (on Rails) CSE 190M, Spring 2009 Week 2. Arrays Similar to PHP, Ruby arrays… – Are indexed by zero-based integer values – Store an assortment of.
A Guide to Unix Using Linux Fourth Edition
Ruby (on Rails) CSE 190M, Spring 2009 Week 3. Web Programming in Ruby Ruby can be used to write dynamic web pages Similar to PHP, chunks of Ruby begins.
The Linux Operating System Lecture 6: Perl for the Systems Administrator Tonga Institute of Higher Education.
CSE S. Tanimoto Perl Introduction 1 Perl Practical Extraction and Report Language Perl: Developed by Larry Wall in the late 1980s. Builds on...
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.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Perl6 Michael Bryson Mark Staton Alex Varghese. Overview  Perl stands for practical extraction and report language  Was written as a language to scan.
Perl Lecture #1 Scripting Languages Fall Perl Practical Extraction and Report Language -created by Larry Wall -- mid – 1980’s –needed a quick language.
Introduction to Perl Software Tools. Slide 2 Introduction to Perl l Perl is a scripting language that makes manipulation of text, files, and processes.
Guide To UNIX Using Linux Third Edition
CSE S. Tanimoto Perl Introduction 1 Perl Practical Extraction and Report Language Shell-level scripting language: Glue that ties together programs.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 8: Perl Basics Fundamentals of Web Programming.
Introduction to PHP. PHP PHP is the Hypertext Pre-processor –Script language –Embedded into HTML –Runs as Apache module –Can use DB (MySQL, Oracle, Microsoft.
August Chapter 1 - Essential PHP spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Introduction to Perl Practical Extraction and Report Language or Pathologically Eclectic Rubbish Lister or …
1 Perl Perl basics Perl Elements Arrays and Hashes Control statements Operators OOP in Perl.
Perl Tutorial Presented by Pradeepsunder. Why PERL ???  Practical extraction and report language  Similar to shell script but lot easier and more powerful.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
4 1 Array and Hash Variables CGI/Perl Programming By Diane Zak.
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
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
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Chapter 9: Perl Programming Practical Extraction and Report Language Some materials are taken from Sams Teach Yourself Perl 5 in 21 Days, Second Edition.
Compound Statements If you want to do more than one statement if an if- else case, you can form a block of statements, or compound statement, by enclosing.
1 Introduction to Perl CIS*2450 Advanced Programming Techniques.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
Chapter Twelve sed, awk & perl1 System Programming sed, awk & perl.
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 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.
CSE S. Tanimoto Perl-Intro - 1 Perl Practical Extraction and Report Language Shell-level scripting language: Glue that ties together programs written.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
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.
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.
Introduction to CGI PROG. CGI stands for Common Gateway Interface. CGI is a standard programming interface to Web servers that gives us a way to make.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Perl Ed Finegan. Overview of Pearl Perl is a high-level programming language written by Larry Wall. It derives from the C programming language and to.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
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 The Internet Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
COMP234-Perl Variables, Literals Context, Operators Command Line Input Regex Program template.
Introduction to Perl: Practical extraction and report language
Ruby: An Introduction Created by Yukihiro Matsumoto in 1993 (named after his birthstone) Pure OO language (even the number 1 is an instance of a class)
PERL.
Cory Redmond Zachary Trim Jeffery Dumas
Programming Basics Web Programming.
Introduction to Programming the WWW I
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during.
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
Introduction to Python
Perl Practical Extraction and Report Language
(Computer fundamental Lab)
Perl Practical Extraction and Report Language
Introduction to Perl Learning Objectives:
Presentation transcript:

Programming with Perl CSCE 330 Group presentation by: Robert Shannon Robert Shannon Ryan Mullaney Ryan Mullaney Anthony So Anthony So

What is Perl?  Started in 1987 by Larry Wall  Practical Extraction and Reporting Language  Originally developed as a utility for UNIX to replace awk  Currently used as replacement for awk, sed, grep, shell scripts, C…  May be referenced as scripting or programming language depending on the source

Features  Why should I learn Perl?   Similar syntax to C therefore familiar to most programmers   Extremely expressive so a few lines of code will do a lot  Typical uses:  (Common Gate-way Interface) – the interaction between the browser & server  World Wide Web through CGI libraries (Common Gate-way Interface) – the interaction between the browser & server   ActiveX scripting   Processing log files   Windows network administration

Timeline  Oct - Perl 1.0 is released  Jun - Perl 2.0 is released  Oct - Perl 3.0 is released  Mar - Perl 4.0 is released  Jan - MacPerl is released  Dec - MacPerl is released  Feb - Perl is released  Oct - MacPerl is released

Timeline continued  Oct - Perl is released  Mar - Perl is released  Aug - MacPerl is released  Jul - Perl 6 announced  Mar - Perl 5.6 is released  Presently - Perl 6 is still in work

Advantages  Perl is compiled every time it is executed  This allows for easy modifications and portability  Unlike interpretive languages Perl must completely compile before any of it runs  This saves many headaches from partially changed text files  A few lines of Perl can do what it would take a complicated C language program to do.  Many built in functions that save time

Disadvantages  Perl is compiled each time it is executed  Since any one can look at your script and change it there is the issue of security  Limited support for data hiding when dealing with classes.  There are no warnings when variables are coerced between types. Example:  Because of this finding logic errors can be hard  Perl offers a number of ways to do the same thing, some more efficient than others, therefore a badly written Perl script can monopolize system resources.

Syntactical conventions CHARTYPEEXAMPLEEXPLANATION #Comment # Yada Rest of the line is a comment $Scalar$price Variable with single value Array of values (indexed by integers) %Hash%grades Group of values (indexed by strings) <>Handle<STDIN> In- & output for files &Subroutine&doit Executable (Perl-) function

Single or Double Quotes  Single quotes are literal. They will pass on exactly what is inside of them. $myname="David"; print 'Hello World! My name is $myname'; RESULTS : Hello World! My name is $myname  Double quotes variables are interpolated and analyzed for values $myname="David"; print "Hello World! My name is $myname"; RESULTS: Hello World! My name is David

Scalars  A scalar is an individual piece of data. In Java it would be the same as a variable.  Scalar data is symbolized by a $ sign.  For correct processing, the $ must be followed by a letter (non-numeric) character.  Scalar names are CaSe SeNsItIvE. $A is different than $a.  Can use up to 255 characters for a scalar name which includes numbers, letters, and underscores.

Scalars continued $answer = 42; # Interger $pi = ; # Floating point $pet = “Camel”;# string $msg = “I love $pet”; # interpolated string $cost = ‘I costs $100’; # not interpolated $idea = ‘Don\’t do it’; # not interpolated $dst = $src; # Copy variables $x = $y + 5; # expression

Scalar Example $a=5; # a contains value of 5 $b=2.5; # b contains value of 2.5 $a=$b + $a; # a now contains value of 7.5 OR OR $mymessage="Hello World!"; print $mymessage; $mymessage="Bye World!"; print $mymessage; # symbol signifies a comment in the code

Arrays  Arrays are groups of data stored in a single spot.  While scalar data use the $ sign, arrays use symbol.  Example: print "Content-type: text/html\n\n"; print "These are the days of the week: "; print  Results: These are the days of the week: Monday Tuesday Wednesday Thursday Friday Saturday Sunday

Array continued  What about accessing an individual array item? print "The value for the fourth array item is $days[3]"; Notice the use of $ and in this instance. Therefore the breakdown = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); Is: $days[0] = "Monday"; $days[1] = "Tuesday"; $days[2] = "Wednesday"; $days[3] = "Thursday"; $days[4] = "Friday"; $days[5] = "Saturday"; $days[6] = "Sunday";

Hashes  Hashes are very similar to an arrays.  A hash is an array of pairs often called an "associative array".  A hash uses the % symbol instead of symbol.  Arrays use 0 to whatever number as an index.  Hashes are keys and value pairs. key, element, key, element, and so on...  Hashes use the curly brackets {} instead of the square brackets [] to find individual elements.

Hash Example %chores = ("Monday", "dishes", "Tuesday", "vacuum", "Wednesday", "garbage"); $value = $chores{Wednesday}; print "$value"; The output of the example script is garbage

Comparison to C C: Void main() { printf(“Hello World!”); }Perl: print ‘Hello World!’

Example of Perl in Action #!c:\perl\bin\perl.exe -w my ($dir); $dir = "."; opendir(DIR, "$dir") || Error("open", "directory"); = readdir(DIR); closedir(DIR) || Error("close", "directory");

sub ren { my ($old_name, $regex = "\.old\$"; $repstr = ".new"; foreach $old_name = $_; $_ =~ s/$regex/$repstr/i; rename($old_name, $_); }} sub Error { print "The server can't $_[0] the $_[1]: $! \n"; }

Sources      