Introduction to perl p ractical e xtraction and r eport l anguage
Sponsored Links
This presentation is the property of its rightful owner.
1 / 12

Introduction to Perl: P ractical e xtraction and r eport l anguage PowerPoint PPT Presentation

  • Uploaded on
  • Presentation posted in: General

Introduction to Perl: P ractical e xtraction and r eport l anguage. Origins Nature of Perl Characteristics of Perl Example. What is Perl?. Includes most powerful constructs from predecessor languages (sh, awk)

Download Presentation

Introduction to Perl: P ractical e xtraction and r eport l anguage

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Introduction to Perl: Practical extraction and report language

  • Origins

  • Nature of Perl

  • Characteristics of Perl

  • Example

What is Perl?

  • Includes most powerful constructs from predecessor languages (sh, awk)

    • From awk (text file processing utility)  Designed to write short programs to process text files, using pattern matching to produce reports of results

    • From UNIX sh, csh process creation and destruction

What is Perl?

  • Added sockets  networking language to support communication with other processes and languages

  • Added modules and OOP

    Added constructs  expressive, flexible language


  • Release 1.000 1987 designed by Larry Wall

  • Began as UNIX tool, but has spread

  • Popularity increased in 1990s

    • Portable systems programming language

    • Easily obtained and free

    • Useful for Common Gateway Interface (CGI) programming for WWW

Language and Programs

  • Simple language – a beginner can write small useful programs

  • Complex language – has a richness and power to perform sophisticated tasks

  • Easy language to learn if you know C, sh or awk

  • Practical (easy to use, efficient, complete), but not beautiful

  • Be disciplined, follow standards  PERL programs will be readable

Scripts vs Programs

  • Early OS/UNIX sh:

    • Small sequence of commands repeatedly typed  put into files and interpreted

    • Hence scripts

  • Perl evolved from shell languages

    • But Perl “scripts” are first compiled into intermediate language before interpreted

    • Hence Programs

Central Characteristics

  • Implicit variables - defined by language implementation, not defined by user, but accessible

  • Variables are implicitly declared – type is inferred by compiler based on name syntax or context

  • Numbers are numbers - one numeric type, same as double (all literals and operations implicitly converted to this type)

  • Strings and numbers – implicit type conversions

  • No unnecessary limits – strings and arrays implicitly grow

Central Characteristics

  • Scalar and list context

    • Array var when scalar expected  length of array

    • Scalar var when array expected  array of 1 element

  • Interchangeability of functions and operations

    • Ex. list operators in which op is followed by operands

    • Ex. Functions have () around operands, but can omit ()

  • More than one way to do it

    • Simple techniques and more complex, elegant alternatives

Getting Perl

  • or My CD

  • Four directories needed:

    • doc – Perl doc (manpages)

    • src – source code files for Perl

    • ports – subdirectories and symbolic links for

    • implementations of Perl not supported by

    • standard distribution

    • scripts – collection of example Perl programs

Other tools

  • Editor – NTEmacs free


  • Debugger – see ActiveState debugger

Example Program

To see listing of environment variables on your computer available to the program


foreach $key (keys (%ENV))


print qq | The value of $key is ENV{"$key"}\n|;


Running Example Program

  • Save as with .pl extension

  • At command prompt type

  • For verbose warnings type perl –w

  • To run with debugger perl –d

  • Login