1 Introduction to Scripting Languages (with Perl).

Slides:



Advertisements
Similar presentations
Everything You Ever Wanted To Know About $# But Couldn’t Google November 13 th, 2014 – Houston Perl Mongers Robert Stone HostGator.com.
Advertisements

Programming Paradigms and languages
A Guide to Unix Using Linux Fourth Edition
Chapter 7:: Data Types Programming Language Pragmatics
Elementary Data Types Prof. Alamdeep Singh. Scalar Data Types Scalar data types represent a single object, i.e. only one value can be derived. In general,
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
1 Pass Compiler 1. 1.Introduction 1.1 Types of compilers 2.Stages of 1 Pass Compiler 2.1 Lexical analysis 2.2. syntactical analyzer 2.3. Code generation.
CSE S. Tanimoto Perl Introduction 1 Perl Practical Extraction and Report Language Perl: Developed by Larry Wall in the late 1980s. Builds on...
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 6: Introduction to Scripting Languages with Python COMP 144 Programming Language.
CS311 – Today's class Perl – Practical Extraction Report Language. Assignment 2 discussion Lecture 071CS Operating Systems I.
Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)
Introduction to PHP. PHP Origins Rasmus LerdorfRasmus Lerdorf (born Greenland, ed Canada) PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP.
Programming with Perl CSCE 330 Group presentation by: Robert Shannon Robert Shannon Ryan Mullaney Ryan Mullaney Anthony So Anthony So.
Perl6 Michael Bryson Mark Staton Alex Varghese. Overview  Perl stands for practical extraction and report language  Was written as a language to scan.
Elementary Data Types Scalar Data Types Numerical Data Types Other
SCRIPTING LANGUAGE. The first interactive shells were developed in the 1960s to enable remote operation of the first time-sharing systems, and these,
Scripting Languages CS351 – Programming Paradigms.
Introduction to a Programming Environment
Guide To UNIX Using Linux Third Edition
Scripting with Ruby What is a scripting language? What is Ruby?
CSE S. Tanimoto Perl Introduction 1 Perl Practical Extraction and Report Language Shell-level scripting language: Glue that ties together programs.
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.
Practical Extraction & Report Language PERL Joseph Beltran.
Introduction to Shell Script Programming
INTERNET APPLICATION DEVELOPMENT For More visit:
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.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
CS 105 Perl: Course Introduction Nathan Clement 13 May 2014.
1 Introduction to Scripting Languages with Python Programming Languages Concepts.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
1 Introduction to Scripting Languages and Perl Basics CSCI 431 Programming Languages Fall 2003 A modification of slides developed by Felix Hernandez-Campos.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Topic 1: Welcome CSE2395/CSE3395 Perl Programming.
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
Introduction to PHP Advanced Database System Lab no.1.
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.
C463 / B551 Artificial Intelligence Dana Vrajitoru Python.
Introduction to Unix – CS 21
1 Introduction to Perl CIS*2450 Advanced Programming Techniques.
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.
Scripting with Ruby What is a scripting language? What is Ruby?
CSE S. Tanimoto Perl-Intro - 1 Perl Practical Extraction and Report Language Shell-level scripting language: Glue that ties together programs written.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
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.
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the 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.
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,
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
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.
PERL SCRIPTING. COMPUTER BASICS CPU, RAM, Hard drive CPU can only use data in the register directly CPU RAM HARD DRIVE.
Programming Languages Meeting 12 November 18/19, 2014.
Week Four Agenda Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems.
Organization of Programming Languages Meeting 37 April 18, 2016.
Introduction to Perl: Practical extraction and report language
Component 1.6.
CS 330 Class 7 Comments on Exam Programming plan for today:
PERL.
Compiler Construction (CS-636)
Perl Programming Language Design and Implementation (4th Edition)
Cory Redmond Zachary Trim Jeffery Dumas
Programming Basics Web Programming.
Perl Practical Extraction and Report Language
Perl Practical Extraction and Report Language
Presentation transcript:

1 Introduction to Scripting Languages (with Perl)

2 Origin of Scripting Languages Scripting languages originated as job control languagesScripting languages originated as job control languages –1960s: IBM System 360 had the Job Control Language –Scripts used to control other programs »Launch compilation, execution »Check return codes Scripting languages got increasingly more powerful in the UNIX worldScripting languages got increasingly more powerful in the UNIX world –Shell programming, AWK, Tcl/Tk, Perl –Scripts used to combine components »Gluing applications [Ousterhout, 97]

3 System Programming Languages System programming languages replaced assembly languagesSystem programming languages replaced assembly languages –Benefits: »The compiler hides unnecessary details, so these languages have a higher level of abstraction, increasing productivity »They are strongly typed, i.e. meaning of information is specified before its use, enabling substantial error checking at compile time »They make programs more portable –SPLs and ALs are both intended to write application from scratch –SPLs try to minimize the loss in performance with respect to ALs –E.g. PL/1, Pascal, C, C++, Java

4 Higher-level Programming Scripting languages provide an even higher-level of abstractionScripting languages provide an even higher-level of abstraction –The main goal is programming productivity »Performance is a secondary consideration –Modern SL provide primitive operations with greater functionality Scripting languages are usually interpretedScripting languages are usually interpreted –Interpretation increases speed of development »Immediate feedback –Compilation to an intermediate format is common

5 Higher-level Programming They are weakly typedThey are weakly typed –I.e. Meaning of information is inferred  Less error checking at compile-time »Run-time error checking is less efficient, but possible Weak typing increases speed of development Weak typing increases speed of development »More flexible interfacing »Fewer lines of code They are not usually appropriate forThey are not usually appropriate for –Efficient/low-level programming –Large programs

6 Typing and Productivity [Ousterhout, 97]

7 Perl (Practical Extraction and Report Language) Larry Wall created Perl in the late 80sLarry Wall created Perl in the late 80s –Wanted a notation that was more powerful than the Unix scripting facilities –Wanted linguistic “naturalness”… shortcuts, choices, defaults, flexibility Perl is dense and richPerl is dense and rich –“Swiss-army chainsaw” –“duct tape for the Web” –“there’s more than one way to do it” –Experienced Perl programmers often reach for the manual when reading others’ code

8 Perl… goals Larry Wall on PerlLarry Wall on Perl –..."I realized at that point that there was a huge ecological niche between the C language and Unix shells," says Wall. "C was good for manipulating complex things -- you can call it 'manipulexity.' And the shells were good at whipping up things -- what I call 'whipupitude.' But there was this big blank area where neither C nor shell were good, and that's where I aimed Perl." Manipulexity vs. whipupitudeManipulexity vs. whipupitude

9 Brief Perl Timeline 1969 Unix created at Bell Labs1969 Unix created at Bell Labs 1977 awk is invented by Aho et al.1977 awk is invented by Aho et al “sh” shell is developed for Unix1978 “sh” shell is developed for Unix 1987 Perl is created by L. Wall1987 Perl is created by L. Wall 1995 Perl released (up to about now)1995 Perl released (up to about now)

10 Perl Defined Original “man” page for PerlOriginal “man” page for Perl Perl is (an) interpreted language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information. It's also a good language for many system management tasks. The language is intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal). It combines (in the author's opinion, anyway) some of the best features of C, sed, awk, and sh, so people familiar with those languages should have little difficulty with it. (Language historians will also note some vestiges of csh, Pascal, and even BASIC|PLUS.) Expression syntax corresponds quite closely to C expression syntax. If you have a problem that would ordinarily use sed or awk or sh, but it exceeds their capabilities or must run a little faster, and you don't want to write the silly thing in C, then perl may be for you. There are also translators to turn your sed and awk scripts into perl scripts. OK, enough hype. OK, enough hype.

11 What Perl Does Well String manipulationString manipulation Text processingText processing File handlingFile handling Regular expressions and pattern matchingRegular expressions and pattern matching Flexible arrays and hashesFlexible arrays and hashes System interactions (directories, files, processes)System interactions (directories, files, processes) CGI scripts for Web sitesCGI scripts for Web sites Has objects, pointers, threads, etc. but these are not the original design goals

12 Perl Overview Perl is interpretedPerl is interpreted –Actually, compiled to bytecode and the bytecode interpreted Every statement ends in semicolonEvery statement ends in semicolon Comments begin with # and extend one lineComments begin with # and extend one line Perl syntax is considered convoluted by some, elegant and efficient by othersPerl syntax is considered convoluted by some, elegant and efficient by others

13 Built-in Data Types No type declarationsNo type declarations –Types are distinguished lexically (by first character) Perl does not have integer, float, boolean, etc. types like other languagesPerl does not have integer, float, boolean, etc. types like other languages –In Perl, these are values of type Scalar Perl has 3 types:Perl has 3 types: –Scalar –Array –Hash (associative array)

14 Built-in Data Types: Scalar ScalarScalar –Integer, real, boolean, string values –Scalar variables begin with $ –$a $A $var1 $fooDeeBar $_ # case matters –$a = 5 ; –$a = 3.5; –$a = “hi there” ; –$a += 2 ; # what happens here?

15 Context… conversions When a scalar is used the value is converted as appropriate for the contextWhen a scalar is used the value is converted as appropriate for the context –$a = 5 ; –$a = $a. “ is a good number” ; # string concatenation –print $a ; –$a = “3.7” ; –$b = $a + 43 ; –print “$b \n”; # string in $a is treated as real number –print ‘$b \n’ ;

16 Built-in Data Types: Array ArrayArray –array variables @fooDeeBar = ( 9, 5, 7.1, “last elt” ) ; –$a[1] = 12 ; –print “first element is $a[0]\n”; –print $#a ; # tells largest used subscript ;

17 Built-in Data Types: Hash HashHash –hash variables begin with % –They are also distinguished by use of { } for subscripts –Subscript can be any scalar (usually a string) –%a = ( “first”, 43, “second”, 26, “third”, 17 ) ; –print $a{‘second’} ; –$a{‘seventeenth’} = ; –$a{‘first’} = 41 ; –$z = “third” ; –$a{$z} = “$z place” ; # what does this do?

18 Built-in Data Types: Hash HashHash –Hashes are very useful for text processing –Build tables, lists, etc. –Built-in functions for getting list of all subscripts (called keys) –For example %a = ( “first”, 21, “seventeenth”, 41, “2nd”, 27, “1”, “one” ); %a = ( “first”, 21, “seventeenth”, 41, “2nd”, 27, “1”, “one” ); foreach ( keys(%a) ) { # loads built-in var $_ with a key foreach ( keys(%a) ) { # loads built-in var $_ with a key print "( $a{$_} ) : $_ \n" ; print "( $a{$_} ) : $_ \n" ; }

19 Reading Assignment John K. Ousterhout, Scripting: Higher-Level Programming for the 21 st Century, 1997John K. Ousterhout, Scripting: Higher-Level Programming for the 21 st Century, 1997 – D. Stotts, The PERL Scripting Language, 2003D. Stotts, The PERL Scripting Language, 2003 –