Perl - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Perl

Description:

Perl works with HTML, XML, and other mark-up languages. ... Eg- caramel=7 where caramel is name of the element and 7 is the value. ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 16
Provided by: vamsi
Category:
Tags: caramel | perl

less

Transcript and Presenter's Notes

Title: Perl


1
Perl
  • Perl is the stable, cross platform language.
  • Perl is a open source software.
  • Perl works with HTML, XML, and other mark-up
    languages.
  • Perl supports both procedural and
    object-orientedprogramming

2
Perl and the web
  • Perl is the most popular web programming language
    due to its text manipulation (or) processing
    capabilities.
  • Perl is called The Duct Tape of Internet.
  • Perl's CGI.pm module, part of Perl's standard
    distribution, makes handling HTML forms simple.
  • Perl can be embedded into web servers to speed up
    processing by as much as 2000.
  • Perl's DBI package makes web-database integration
    easy.

3
Basics of Perl
  • Names of scalar variables begin with sign.
  • Compiler declares variables implicitly when it
    encounters
  • All numeric operations are done in floating point
    precision.
  • Eg-5/2 2.5 in Perl
  • Scalar variable which has not been assigned a
    value will has the value undef.

4
String Functions
  • chomp-removes any terminating new line character
    from its parameter.
  • length-Returns the length of the string.
  • lc-converts the parameter string to the
    uppercase letters.
  • uc- converts the parameter string to the
    uppercase letters.
  • join-returns the string constructed by
    concatenating the strings together them.

5
Input and Output
  • Input and output can be thought of file input and
    file output.
  • Files are referenced in programs through internal
    filenames called File handles.
  • They are-STDIN
  • STDOUT
  • STDERR
  • add.pl

6
Control Expression
  • Perl has the loops same as any other languages
  • While loop
  • For loop
  • BIGLOOP
  • while()
  • while()
  • .
  • if(.)last BIGLOOP
  • .
  • .

7
Arrays
  • Arrays in Perl are different in 3-ways
  • Dynamic
  • Can have absent elements
  • They can store different types of data.
  • The array variables are preceded by _at_ sign.
  • Eg- _at_list2,4,6
  • list258
  • The length of the array is specified by list1.

8
Array functions
  • PUSH
  • POP
  • SORT
  • SHIFT
  • UNSHIFT
  • Push and Pop deal with the right end of the
    arrays
  • Shift and Unshift deal with the left end of the
    arrays
  • uppercase.pl

9
Hashes
  • Perl associative arrays are called Hashes.
  • Two differences between arrays and hashes are-
  • Arrays use numeric subscripts where as hashes
    use string values for element addressing.
  • Elements in arrays are ordered by subscripts
    whereas in hashes they are like set.
  • Eg- kids_agesJohngt12,Gennygt33

10
Functions
  • The function header is the reserved word sub.
  • A function can specify the return values in
    2-ways either implicitly or explicitly.
  • If there are no calls for the return statement
    with in the function then the return value is the
    value of the last expression encountered.
  • Local variables are declared in the function
    using the reserved word my.
  • It has also another reserved word local for
    declaring local variables.
  • All the parameters are passed to a function are
    placed in _at__.
  • Every function has its own version of _at__.
  • median.pl

11
CGI
  • Common Gateway Interface
  • A programming interface between a web server and
    the systems backend functions - such as
    processing systems and databases. Allows web
    servers to perform data functions and interact
    with users.
  • (or) A protocol that is used between a browser
    and software on the server is called CGI.

12
Life cycle of CGI program
  • The CGI program takes the user input .
  • Takes the decision based on the input what action
    is to be taken.
  • Does the action and responds to the user by
    creating the response web page.
  • Exits

13
  • Steps for building the CGI Applications-
  • CGI programs often reside in a specific directory
    on the server. Eg- cgi-bin
  • The server should be configured so that it can
    recognize the CGI and Perl programs.
  • When a server receives a request for a CGI
    program it executes the CGI program and returns
    the output to the browser.
  • Using the CGI a browser can run the programs on
    the server indirectly.

14
Query String Format
  • Http requests made by the users through the
    methods like GET and POST using FORMS transmit
    the data associated with the request in the form
    of character strings called Query String.
  • The elements of the form that has the name and
    value are coded as a character strings namevalue
    and included in the Query String.
  • Eg- caramel7 where caramel is name of the
    element and 7 is the value .
  • The special characters are coded by sign.

15
CGI.pm Module
  • Perl programs access a particular module with the
    use declaration.
  • use CGI standard
  • The functions of the CGI.pm module which are used
    to create the required XHTML tags are called
    SHORTCUTS.
  • Eg- print br implies ltbr /gt
  • Cookie example--
Write a Comment
User Comments (0)
About PowerShow.com