introduction to perl p ractical e xtraction and r eport l anguage
Download
Skip this Video
Download Presentation
Introduction to Perl: P ractical e xtraction and r eport l anguage

Loading in 2 Seconds...

play fullscreen
1 / 12

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


  • 89 Views
  • Uploaded on

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)

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Introduction to Perl: P ractical e xtraction and r eport l anguage' - nancy


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 p ractical e xtraction and r eport l anguage
Introduction to Perl: Practical extraction and report language
  • Origins
  • Nature of Perl
  • Characteristics of Perl
  • Example
what is perl
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 perl1
What is Perl?
  • Added sockets  networking language to support communication with other processes and languages
  • Added modules and OOP

Added constructs  expressive, flexible language

history
History
  • 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
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
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
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 characteristics1
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
Getting Perl
  • www.activestate.com 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
Other tools
  • Editor – NTEmacs free
    • www.cs.washington.edu/hones/voelker/ntemacs
  • Debugger – see ActiveState debugger
example program
Example Program

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

#!/usr/local/bin/perl

foreach $key (keys (%ENV))

{

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

}

running example program
Running Example Program
  • Save as with .pl extension
  • At command prompt type filename.pl
  • For verbose warnings type perl –w filename.pl
  • To run with debugger perl –d filename.pl
ad