Your SlideShare is downloading. ×
  • Like
Perl  programming tsp
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Perl programming tsp

  • 1,135 views
Published

 

Published in Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,135
On SlideShare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
13
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Perl Programming
  • 2. Topics
    Introduction to Perl
    Variables
    Scalars
    Arrays
    Hashes
    Regular Expressions
  • 3. Introduction
    Perl – Practical Extraction and Reporting Language
    Developed in 1987 by Larry Wall
    Filenames should have the extension of .pl
    Runs under windows and linux
    The first line of perl under linux is
    #!/usr/bin/perl
    The first line of perl under windows is
    #!c:/perl/bin/perl.exe
  • 4. Introduction
    Perl scripts are interpreted in the command or shell prompt and even in the browser.
    If it in the browser, a Http header should be set like
    print “Content-type: text/html nn”;
    First example
    #! C:/perl/bin/perl.exe
    print “Content-type: text/html nn”;
    Print “Hello World “;
  • 5. Introduction
    Go to the command prompt and execute the command
    perl filename.pl
    In the browser, type http://localhost/filename.pl
  • 6. Perl Variables
    Scalars ($)
    Numbers or Strings or reference
    Started with a $ symbol
    Ex. $string=“Hello “; $a=200; $x=2**3;
    Arrays (@)
    List of scalar data
    Defined by an @ symbol
    @s=(“hello”, ”world”);
    Hashes (%)
    Complex list with both a key and a value part for each element of the list.
    Defined by a % symbol
    %ages = ("Jerry", 45, "Tom", 22, "Vickie", 38);
  • 7. Scalars
    $x = 12345; # integer
    $x = 12345.67; # floating point
    $x = 6.02e23; # scientific notation
    $x = 4_294_967_296; # underline for legibility
    $x = 0377; # octal
    $x = 0xffff; # hexadecimal
    $x = 0b1100_0000; # binary
    $x=“Hello” # string literals
    Double quotes – variables are interpolated
    Single quotes – variables are not interpolated
  • 8. Arrays
    @a=(“hi”,”Hello”,”there”);
    Print @a;
    $c=pop @a; # last element “there” is stored in c
    Push(@a,”here”);
    Print @a;
    Print $a[0]; #index starts at 0, so prints hi
  • 9. Hashes
    Uses a key value pair
    Key is usually a string literal
    Example
    %hash=(“Tom”,33,”mike”,23,”john”,19);
    Print %hash;
    @k=keys %hash;
    @v=values %hash;
    $count=keys %hash;
    While(($keys=>$values)=each %hash)
    {print “$keys=>$values”.”<br/>”;}
  • 10. Regular Expression
    Matches a word or a phrase or even a character trying to match a pattern
    Meta characters
    Pattern Modifiers