1 / 20

CS 105 Perl: Course Introduction

CS 105 Perl: Course Introduction. Nathan Clement 13 May 2014. Agenda. Course overview Review syllabus Informal survey Next class: paper survey Perl introduction. Perl origins. Larry Wall Graduate study in linguistics System administrator at NASA Perl 1.0 in 1987. Perl 1.000. NAME

demont
Download Presentation

CS 105 Perl: Course Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 105 Perl:Course Introduction Nathan Clement 13 May 2014

  2. Agenda • Course overview • Review syllabus • Informal survey • Next class: paper survey • Perl introduction

  3. Perl origins Larry Wall • Graduate study in linguistics • System administrator at NASA • Perl 1.0 in 1987

  4. Perl 1.000 NAME perl | Practical Extraction and Report Language SYNOPSIS perl [options] filename args DESCRIPTION Perl is a interpreted language optimized for scanning arbi- trary 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, effi- cient, 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 fas- ter, 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.

  5. Perl over time Path to Maturity • Perl 1.000 – December 18, 1987 • Perl 2.000 – June 5, 1988 • Perl 3.000 – October 18, 1989 • Perl 4.000 – March 21, 1991 • Perl 5.000 – October 18, 1994 • “Complete rewrite” • Perl 6.000 - ??? • Project announced on July 19, 2000 • “eventually evolved into a separate language”

  6. Perl over time Path to Maturity • Perl 1.000 – December 18, 1987 • Perl 2.000 – June 5, 1988 • Perl 3.000 – October 18, 1989 • Perl 4.000 – March 21, 1991 • Perl 5.000 – October 18, 1994 • “Complete rewrite” • “Perl” means Perl5

  7. Getting the name right • Perl • Not PERL • The language is Perl • The interpreter is perl • Originally named Pearl • Some “backronyms” are in common use • Practical Extraction and Report Language • Pathologically Eclectic Rubbish Lister

  8. More Perl culture • There’s more than one way to do it(TMTOWTDI) • Golfing • Conciseness • Terseness • Obfuscation

  9. Do What I Mean Do What I Mean (DWIM) The evolution of DWIM: DWIM →DWIMmy→dwimmy “perldwimmy” on Google: • “So non-dwimmy open variants are a good idea to keep around” • “Non-dwimmyhyperoperator” • “I don’t think this is DWIMMY at all.” • “that seems to be pretty dwimmy”

  10. Programming Taxonomy:Where Perl Fits In Perl… • is interpreted • Compiled at runtime into bytecode • Bytecode is interpreted • is dynamically typed • Variables don’t have types • Values have types • has automatic memory management • Memory is not allocated by the programmer • No malloc/free, new/delete analogue These features are typical of “scripting languages”

  11. Programming Taxonomy:Perl’s Relatives Just a few similar languages: • Python • PHP • Ruby

  12. So Why Perl? Perl Python PHP

  13. What is Perl good for? • Text processing • Data manipulation (“munging”) • Quick development of tools • One-offs • System integration • “Glue” code • Databases, Web, etc. • “Real” systems

  14. What is good about Perl? • Very quick development • Once you learn it • Easy things are easy, and typically short • Great documentation • Lots of books • Installed out of the box on many Unix platforms • or easily available as a package • Typically comes “batteries included” • Especially since Perl 5.8 (2002) • Huge collection of free modules (CPAN)

  15. Your first Perl program • Create a file • Open your editor • Save an empty file • In another terminal, type perlthat-file • This is one way to run your program

  16. Your second Perl program Type the following: print "Some boring text\n"; Save your file and run it.

  17. Running Your Program Directly (1) We don’t want to type perl your-program We’d rather type ./your-program

  18. Running Your Program Directly (2) Very first line At the top of your program, type the following: #!/usr/bin/perl This tells the program loader how to run your program. From a terminal (outside your editor), type chmod +x your-program This marks the file as executable so Unix will allow it to execute. “Hash-bang” line

  19. Homework Write your own Hello, World program that I can run like ./foo. I don’t care what you print out, as long as it prints something. This will require: • getting a Unix account • learning the rudimentary features of an editor • writing one correct Perl statement • learning how to use turnin

  20. Homework Due Date • Assignment 1 is due Wednesday, January 22,but I recommend completing it ASAP.

More Related