Perl A language for Systems and Network Administration and Management.

Slides:



Advertisements
Similar presentations
A Guide to Unix Using Linux Fourth Edition
Advertisements

Bioinformatics is … - the use of computers and information technology to assist biological studies - a multi-dimensional and multi-lingual discipline Chapters.
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.
Drew Murphy Drew Ebelhar. History December 18, 1987 Creator- Larry Wall Objective: To develop a general purpose Unix scripting language to make report.
Python Jordan Miller and Lauren Winkleman CS 311 Fall 2011.
Introduction to Perl Software Tools. Slide 2 Introduction to Perl l Perl is a scripting language that makes manipulation of text, files, and processes.
Perl R and SQL for the very beginners Christoph Rau, Calvin Pan and Yehudit Hasin Dec 2011.
CMSC 202 Computer Science II for Majors Fall 2009 Introduction.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 8: Perl Basics Fundamentals of Web Programming.
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 03.
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
Introduction to Perl Practical Extraction and Report Language or Pathologically Eclectic Rubbish Lister or …
CMSC 202 Computer Science II for Majors Object-Oriented Programming.
1 Perl Perl basics Perl Elements Arrays and Hashes Control statements Operators OOP in Perl.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Just as there are many human languages, there are many computer programming languages that can be used to develop software. Some are named after people,
Perl and Regular Expressions Regular Expressions are available as part of the programming languages Java, JScript, Visual Basic and VBScript, JavaScript,
Introduction to Perl Yupu Liang cbio at MSKCC
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.
Chapter 9: Perl Programming Practical Extraction and Report Language Some materials are taken from Sams Teach Yourself Perl 5 in 21 Days, Second Edition.
CIT 383: Administrative ScriptingSlide #1 CIT 383: Administrative Scripting Introduction.
Intermediate CGI & CGI.pm Webmaster II - Fort Collins, CO Copyright © XTR Systems, LLC CGI Programming & The CGI.pm Perl Module Instructor: Joseph DiVerdi,
An Overview of Perl A language for Systems and Network Administration and Management: An overview of the language.
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.
Introduction Mehdi Einali Advanced Programming in Java 1.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
HTML HyperText Markup Language Victoria E. Kozlek.
The Scripting Programming Language
Dept. of Animal Breeding and Genetics Programming basics & introduction to PERL Mats Pettersson.
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.
Software Development Languages and Environments. Computer Languages Just as there are many human languages, there are many computer programming languages.
Introduction to PHP. PHP Origins Rasmus LerdorfRasmus Lerdorf (born Greenland, ed Canada) PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP.
Presented By Sushil K. Chaturvedi Assistant Professor SRCEM,Banmore 1.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Organization of Programming Languages Meeting 37 April 18, 2016.
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 Basics and Syntax Lesson 3 ITBS2203 E-Commerce for IT.
Web Database Programming Using PHP
Introduction to Perl: Practical extraction and report language
The language focusses on ease of use
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Top 8 Best Programming Languages To Learn
CS 330 Class 7 Comments on Exam Programming plan for today:
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
GO! with Microsoft Office 2016
PERL.
PERL.
Web Database Programming Using PHP
Cory Redmond Zachary Trim Jeffery Dumas
Programming Basics Web Programming.
GO! with Microsoft Access 2016
PHP (PHP: Hypertext Preprocessor)
PHP / MySQL Introduction
PHP Introduction.
CSE1320 INTERMEDIATE PROGRAMMING
USING ADOBE ACROBAT READER DC
CSE1320 INTERMEDIATE PROGRAMMING
Introduction to Python
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
Creating your first C program
강의 내용 및 방법 접근방법 리포트 시험 Lambda Calculus, Proof of Correctness
CSC 142 Introduction to Java [Reading: chapters 1 & 2]
Let’s start from the beginning
Introduction to Perl Learning Objectives:
Perl Programming Dr Claire Lambert
CS313T Advanced Programming language
Presentation transcript:

Perl A language for Systems and Network Administration and Management

Systems and Network ManagementPerl — an Introduction2 What is Perl? Perl is a programming language The best language for processing text Cross platform, free, open Microsoft have invested heavily in ActiveState to improve support for Windows in Perl Has excellent connection to the operating system Has enormous range of modules for thousands of application types

Systems and Network ManagementPerl — an Introduction3 What is Perl?2 Robust and reliable (has very few bugs) Supports object oriented programming Good for big projects as well as small Java 1.4 has borrowed one of Perl’s best features: regular expressions Perl has garbage collection The “duct tape of the Internet” Easy to use, since it usually “does the right thing” Based on freedom of choice: “There is more than one way to do it!” TIMTOWTDI

Systems and Network ManagementPerl — an Introduction4 Compiled and run each time Perl is interpreted, but runs about as fast as a Java program Software development is very fast The Apache web server provides mod_perl, allows Perl applications to run very fast Used on some very large Internet sites: –The Internet Move Database –Macromedia, Adobe,

Systems and Network ManagementPerl — an Introduction5 Perl is Evolving Perl 6 will introduce many great features to make Perl –easier to use –Even more widely usable for more purposes –Even better for bigger projects

Systems and Network ManagementPerl — an Introduction6 Eclectic Borrows ideas from many languages, including: –C, C++ –Shell –Lisp –BASIC –…even Fortran –Many others…

Systems and Network ManagementPerl — an Introduction7 Regular Expressions One of the best features of Perl A new concept for most of you …But very useful! Used to: –extract information from text –transform information You will spend much time in this topic learning about regular expressions

Systems and Network ManagementPerl — an Introduction8 Why should I learn it? It will be in the final exam! –Okay, that’s to get your attention, but… Consider a real-life sys-admin problem: –You must make student accounts for 1500 students –TEACHING BEGINS TOMORROW!!! –The Computing Division has a multi-million dollar application to give you student enrollment data –…but it can only give you PDF files with a strange and irregular format for now (But Oh, it will be infinitely better in the future! Just wait a year or two…)

Systems and Network ManagementPerl — an Introduction9 The available data Has a variable number of lines before the student data begins Has a variable number of columns between different files Has many rows per enrolled student Goes on for dozens of pages, only 7 students per page!!!!!!! There are two formats, both equally peculiar!!!!

Systems and Network ManagementPerl — an Introduction10 Sample data for new courses: 15 N CHAN Wai Yee F H123456(5) CHEUNG 10-SEP SEP WAI CHI SISTER

Systems and Network ManagementPerl — an Introduction11 Problems There is a different number of lines above the student records There is a different number of characters within each column from file to file There are many files The format can change any time the computing division determines necessary

Systems and Network ManagementPerl — an Introduction12 Solution in Perl #! /usr/bin/perl -w use strict; my $course; my $year; while ( <> ) { chomp; if ( /^\s*Course :\s(\d+)\s/ ) { $course = $1; undef $year; next; } elsif ( m!^\s*Course :\s(\d+)/(\d)\s! ) { $course = $1; $year = $2; next; } if ( my ( $name, $gender, $student_id, $hk_id ) #= m!\s\s+([A-Z]+(?: [A-Z][a-z]*)+)\s\s+([MF])\s+(\d{9})\s\s+([a-zA-Z]\d{6}\([\dA-Z]\))! ) = m{ \s\s+ # at leaset 2 spaces ( # this matches $name [A-Z]+ # family name is upper case (?:\s[A-Z][a-z]*)+ # one or more given names ) \s\s+ # at leaset 2 spaces ([MF]) # gender \s+ # at least one space (\d{9}) # student id is 9 digits \s\s+ # at leaset 2 spaces ([a-zA-Z]\d{6}\([\dA-Z]\)) # HK ID }x ) { print "sex=$gender, student ID = $student_id, ", "hkID = $hk_id, course = $course, name=$name, ", defined $year ? "year = $year\n" : "\n"; next; } warn "POSSIBLE UNMATCHED STUDENT: $_\n" if m!^\s*\d+\s+!; }

Systems and Network ManagementPerl — an Introduction13 But I can use any other language! I will give you HK$200 if you are the first person to write a solution in another language in fewer keystrokes Note: the Perl solution given has: –comments –Plenty of space to show structure –…and handles exceptional situations (i.e., it is robust) To claim your $200 from Nick, your solution must have –similar space for comments –Similar readability and robustness –Be written in a general purpose language using ordinary libraries

Systems and Network ManagementPerl — an Introduction14 Any other solution may take longer to write This program took a very short time to write It is very robust For problems like this, Perl is second to no other programming language.

Systems and Network ManagementPerl — an Introduction15 The hello world program print “hello world\n”

Systems and Network ManagementPerl — an Introduction16 Variables There are three basic types of variable: Scalar (can be a number or string or…) Array (an ordered array of scalars) Hash (an unordered array of scalars indexed by strings instead of numbers) Each type distinguished with a “funny character”

Systems and Network ManagementPerl — an Introduction17 $Scalars: Start with a dollar sign Hold a single value, not a collection A string is a scalar, so is a number Examples: $apple = 2; $banana = “curly yellow fruit”;

Systems and Network ManagementPerl — an Starts with Indexes start at 0, like in C

Systems and Network ManagementPerl — an Introduction19 %Hashes Unfamiliar concept to many of you Like an array, but indexed by a string A data structure like a database

Systems and Network ManagementPerl — an Introduction20 Conclusion Perl is optimised for text and systems administration programming Has great portability Is strongly supported by Microsoft Has three main built-in data types: –Scalar: starts with $ –Array: starts –Hash: starts with %