SlideShare ist ein Scribd-Unternehmen logo
1 von 62
Perl Sopan Shewale,  [email_address]
Hello World – First Program $ cat HelloWorld.pl #!/usr/bin/perl print "Welcome to the world of Perl Programming !"; $ chmod +x HelloWorld.pl $ ./HelloWorld.pl Welcome to the world of Perl Programming ! $ perl HelloWorld.pl Welcome to the world of Perl Programming ! Make it executable Execute it Another Way to Execute
Another Simple Example – Taking input from user  [sopan@ps3724 tutorial]$ cat InteractiveHello.pl #!/usr/bin/perl my $user; print &quot;Please write your name:&quot;; $user = <STDIN>; print &quot;Welcome to the world of perl, You are : $user&quot;;
Simple example – way to execute external command [sopan@ps3724 tutorial]$ cat df.pl #!/usr/bin/perl print &quot;Method1:&quot;; my $out1 = system(&quot;df -k&quot;); print &quot;The output of df -k command is : $out1&quot;; Method1: Filesystem  1K-blocks  Used Available Use% Mounted on /dev/hda8  19346964  10931664  7432528  60% / /dev/hda1  101089  14826  81044  16% /boot /dev/hda3  15116868  12328832  2020132  86% /home none  252056  0  252056  0% /dev/shm /dev/hda5  8064272  5384612  2270008  71% /usr /dev/hda6  3020140  307088  2559636  11% /var /dev/hda2  30233928  8830792  19867324  31% /usr/local The output of df -k command is : 0
Simple example – way to execute external command print &quot;Method2:&quot;; my $out2 = `df -k`; print &quot;The output of df -k command is : $out2&quot;; Method2: The output of df -k command is : Filesystem  1K-blocks  Used Available Use% Mounted on /dev/hda8  19346964  10931664  7432528  60% / /dev/hda1  101089  14826  81044  16% /boot /dev/hda3  15116868  12328832  2020132  86% /home none  252056  0  252056  0% /dev/shm /dev/hda5  8064272  5384612  2270008  71% /usr /dev/hda6  3020140  307088  2559636  11% /var /dev/hda2  30233928  8830792  19867324  31% /usr/local [sopan@ps3724 tutorial]$
An introduction to Simple Stuff ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Exercise  ,[object Object],[object Object],[object Object],gcd (a, b) { if (b < a ) {  swap (a, b);  } While (b) {  r = b % a; a = b; b = r; } return a; }
Directory and File Operations ,[object Object],[object Object],[object Object],[object Object],[object Object],Exercise– Write the program to monitor given set of hosts in the network.
Arrays and Functions ,[object Object],[object Object],[object Object],[object Object],[object Object]
Exercise – long assignement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1975:Won:West Indies 1975:Lost:Australia 1979:Won:West Indies 1979:Lost:England 1983:Won:India 1983:Lost:West Indies 1987:Won:Australia 1987:Lost:England 1992:Won:Pakistan 1992:Lost:England 1996:Won:Srilanka 1996:Lost:Australia
grep and map functions ,[object Object],my @result = grep EXPR @input_list; my $count = grep EXPR @input_list; my @input_numbers = (1, 4, 50, 6 14); my @result = grep $_>10, @input_numbers; Transforming Lists with Map  my @input_list = (1, 4, 10, 56, 100); my @result = map  $_ + 100,  @input_list; my @next_result = map ($_, 5*$_), @input_list; my %hash_result =map ($_, $_*$_), @input_list;
Exercise ,[object Object],[object Object],[object Object],[object Object]
Regular Expression ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Regular expression (Cont…) Let us look at the example   if (&quot;Hello  World &quot; =~ /World/) {  print  &quot;It matches&quot;;  }  else  {  print  &quot;It doesn't match&quot;; }  The sense of  =~  is reversed by  !~  operator.
Regular Expression (Cont…) The literal string in the regexp can be replaced by a variable:  $greeting = &quot;World&quot;;  if (&quot;Hello World&quot; =~ /$greeting/) {  print  &quot;It matches&quot;;  } else  {  print  &quot;It doesn't match&quot;; }  Regexp’s are case sensitive
Regular Expression (Cont…) ,[object Object],[object Object],&quot;Hello World&quot; =~ /o/; # matches 'o' in 'Hello'  &quot;That hat is red&quot; =~ /hat/; # matches 'hat' in 'That'  &quot;2+2=4&quot; =~ /2+2/; # doesn't match, + is a metacharacter  &quot;2+2=4&quot; =~ /22/; # matches,  is treated like an ordinary +  Some characters, called  metacharacters , are reserved for use in regexp notation. List is :  {}[]()^$.|*+?
[object Object],[object Object],[object Object],Regular Expression (Cont…) %vi  simple_grep  #!/usr/bin/perl  $regexp =  shift ;  while (<>) {  print  if /$regexp/; } &quot;housekeeper&quot; =~ /keeper/; # matches  &quot;housekeeper&quot; =~ /^keeper/; # doesn't match  &quot;housekeeper&quot; =~ /keeper$/; # matches  &quot;housekeeper&quot; =~ /keeper$/; # matches  &quot;keeper&quot; =~ /^keep$/; # doesn't match &quot;keeper&quot; =~ /^keeper$/; # matches &quot;&quot; =~ /^$/; # ^$ matches an empty string  Grep Kind of example
Using character classes ,[object Object],[object Object],$x = 'bcr';  /[$x]at/; # matches 't', 'bat, 'cat', or 'rat'  /item[0-9]/; # matches 'item0' or ... or 'item9'  /[0-9bx-z]aa/; # matches '0aa', ..., '9aa', /cat/; # matches 'cat'  /[bcr]at/; # matches 'bat, 'cat', or 'rat'  /item[0123456789]/; # matches 'item0' or ... or 'item9‘ &quot;abc&quot; =~ /[cab]/; # matches 'a'  In the last statement, even though 'c' is the first character in the class, 'a‘ matches because the first character position in the string is the earliest point at which the regexp can match.  Regular Expression (Cont…)
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Regular Expression (Cont…)
Matching this or that ,[object Object],&quot;cats and dogs&quot; =~ /cat|dog|bird/;  # matches &quot;cat&quot;  &quot;cats and dogs&quot; =~ /dog|cat|bird/;  # matches &quot;cat&quot; Regular Expression (Cont…)
Grouping things and hierarchical matching ,[object Object],[object Object],/(a|b)b/; # matches 'ab' or 'bb‘ /(ac|b)b/; # matches 'acb' or 'bb'  /(^a|b)c/; # matches 'ac' at start of string or 'bc' anywhere  /(a|[bc])d/; # matches 'ad', 'bd', or 'cd'  /house(cat|)/; # matches either 'housecat' or 'house‘ /house(cat(s|)|)/; # matches either 'housecats' or 'housecat' or  # 'house'. Note groups can be nested.  /(19|20|)/; # match years 19xx, 20xx, or the Y2K problem, xx  &quot;20&quot; =~ /(19|20|)/; # matches the null alternative '()', # because '20' can't match  Regular Expression (Cont…)
[object Object],[object Object],[object Object],[object Object],[object Object],&quot;abcde&quot; =~ /(abd|abc)(df|d|de)/;  Regular Expression (Cont…)
[1].  Start with the first letter in the string 'a'. [2].  Try the first alternative in the first group 'abd'. [3].  Match 'a' followed by 'b'. So far so good. [4].  'd' in the regexp doesn't match 'c' in the string – a dead end. So backtrack  two characters and pick the second alternative in the first group 'abc'. [5].  Match 'a' followed by 'b' followed by 'c'. We are on a roll and have satisfied the first group. Set $1 to 'abc'. [6].  Move on to the second group and pick the first alternative 'df'. [7].  Match the 'd'. [8].  'f' in the regexp doesn't match 'e' in the string, so a dead end. Backtrack  one character and pick the second alternative in the second group 'd'. [9].  'd' matches. The second grouping is satisfied, so set $2 to 'd'. [10].  We are at the end of the regexp, so we are done! We have matched 'abcd' out of the string &quot;abcde&quot;. Regular Expression (Cont…)
Extracting Matches ,[object Object],[object Object],[object Object],# extract hours, minutes, seconds  if ($time =~ /():():()/) {  # match hh:mm:ss format  $hours = $1;  $minutes = $2;  $seconds = $3;  }  Regular Expression (Cont…)
Matching Repetitions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Regular Expression (Cont…)
A few Principles ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Regular Expression (Cont…)
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],A few Principles Regular Expression (Cont…)
[object Object],[object Object],[object Object],$x = &quot;The programming republic of Perl&quot;;  $x =~ /^(.+)(e|r)(.*)$/;  # matches,  # $1 = 'The programming republic of Pe'  # $2 = 'r'  # $3 = 'l'  Regular Expression (Cont…)
Exercise  ,[object Object],[object Object],[object Object]
Regular Expression – Match the positive Integer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Question:  Determine whether a string contains a positive integer. Discussion:
Hashes ,[object Object],[object Object],my %fruit;  $fruit{&quot;red&quot;} = &quot;apple&quot;; $fruit{&quot;orange} = &quot;orange&quot;;  $fruit{&quot;purple&quot;} = &quot;grape&quot;;  %fruit = (&quot;red&quot;, &quot;apple&quot;, &quot;orange&quot;, &quot;orange&quot;, &quot;purple&quot;, &quot;grape&quot;);  %fruit = (          &quot;red&quot; => &quot;apple&quot;,          &quot;orange&quot; => &quot;orange&quot;,          &quot;purple&quot; => &quot;grape&quot;,  );
[object Object],[object Object],[object Object],[object Object],Functions on Hashes #vi fruit.pl my %fruit = (          &quot;red&quot; => &quot;apple&quot;,          &quot;orange&quot; => &quot;orange&quot;,          &quot;purple&quot; => &quot;grape&quot;,  ); for (keys %fruit) { print “$_ : $fruit{$_} ”; } Why use Hash?  Write a program which takes the input the city/capital name and returns the country name by Using Arrays and Hashes or  any other method. So you know why use Hashes.
References # Create some variables  $a = &quot;mama mia&quot;;  @array = (10, 20);  %hash = (&quot;laurel&quot; => &quot;hardy&quot;, &quot;nick&quot; => &quot;nora&quot;); # Now create references to them  $ra = a;  # $ra now &quot;refers&quot; to (points to) $a  $rarray = array;  $rhash = hash;  #You can create references to constant scalars in a similar fashion: $ra = 0;  $rs = amp;quot;hello world&quot;;
References ,[object Object],#Look nicely: @array = (10, 20); $ra = array; is similar to $ra =[10, 20] # Notice the square braces. %hash = (&quot;laurel&quot; => &quot;hardy&quot;, &quot;nick&quot; => &quot;nora&quot;);  $rhash = hash is similar to $rhash = { “laurel”=>”hardy”, “nick” => “nora” }; $ra = a; # First take a reference to $a  $$ra += 2; # instead of $a += 2;  print $$ra; # instead of print $a  $rarray = array; push (@array , &quot;a&quot;, 1, 2); # Using the array as a whole  push (@$rarray, &quot;a&quot;, 1, 2); # Indirectly using the ref. to the array  $rhash = hash; print $hash{&quot;key1&quot;}; # Ordinary hash lookup print  $$rhash{&quot;key1&quot;}; # hash replaced by $rhash
[object Object],$rarray = array;  print $rarray->[1] ; # The &quot;visually clean&quot; way  $rhash = hash;  print $rhash->{&quot;k1&quot;}; #instead of ........  print $$rhash{&quot;k1&quot;}; # or  print ${$rhash}{&quot;k1&quot;};  References
Subroutines ,[object Object],[object Object],[object Object],#Defining subroutine: sub mysubroutinename { #### code to do that } ,[object Object],[object Object],[object Object],[object Object]
Modules ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
 
[object Object],[object Object],[object Object],[object Object],Modules (Cont…)  Package SayHello; sub hello_package { return “Hello, Welcome to the world of Modules”; } 1;
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],use and require – what is that?
 
[object Object],[object Object],[object Object]
 
CGI  ,[object Object],[object Object],[object Object],[object Object]
Example: Count Click Script #!/usr/bin/perl ######################### ## Author: Sopan Shewale ## Company: Persistent Systems Pvt Ltd ## This script is created for giving demo on click count. ## The Script is support to display increse/decrease  ##click's, handles back button of browser, does not  ##handle reload stuff. ## also it's based on sessions. ######################## use strict; use warnings; use CGI; use CGI::Session; use CGI::Cookie; my $q = new CGI(); my $sessionid = $q->cookie(&quot;CGISESSID&quot;) || undef; my $session = new CGI::Session(undef, $sessionid, {Directory=>'/tmp'}); $sessionid = $session->id(); my $cookie = new CGI::Cookie(-name=>'CGISESSID',  -value=>$sessionid, -path=>&quot;/&quot;); print $q->header('text/html', -cookie=>$cookie); print $q->start_html(&quot;Welcome to Click Count Demo&quot;); print &quot;<h1>Welcome to Click Count Demo</h1>&quot;; my $count = $session->param('count');  ## count-is click count variable if(!defined($count)) { $session->param('count', 0);  $count=0;}  ### if session is first time created, set count=0 $session->param('count', $count); $count = $session->param('count'); #print &quot;<h1>The Click Count is: $count &quot;; ## Form stuff print $q->startform(-method=>'POST'); print $q->submit( -name=>&quot;Increase&quot;, -value=>'Increase1'); print $q->submit( -name=>&quot;Decrease&quot;, -value=>'Decrease1'); print $q->endform();
Example: Count Click Script (Cont…) ## Which button is being pressed my $which_button = $q->param('Increase'); if(defined ($which_button)) { print &quot;Increase pressed&quot;; $count = increase_count($count);  ## Increase the count since increase button is clicked $session->param('count', $count); }else { $which_button=$q->param('Decrease'); if(defined($which_button)){ print &quot;Decrease pressed&quot;; $count = decrease_count($count);  ## Decrease the count since decrease button is clicked $session->param('count', $count); } else {print &quot;You have not pressed any button,  seems you are typing/re-typing the same URL&quot;; } } $count = $session->param('count'); print &quot;<h1>The Click Count is: $count &quot;; print $q->end_html(); ## increases the count by 1 sub increase_count { my $number = shift; $number = $number +1; return $number; } ## decreases the count by 1 sub decrease_count { my $number = shift; $number = $number -1; return $number; }
Using eval ,[object Object],[object Object],[object Object],[object Object]
Data::Dumper
TWiki
bin:  view, edit, search etc tools:  mailnotify template:  Templates (view.tmpl), also has skin related data lib:  modules and required libraries, plugin code data:  webs directories (e.g. Main,TWiki) and each directory inside contains the topics from that web. The topics are companied by there version history pub:  Attachments of the topics and commonly shared data
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],TWiki (Cont…)
TWiki (Cont…) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],TWiki (Cont…)
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],TWiki (Cont…)
[object Object],%HELLO{format=“Dear $first $last, $brWelcome to the world of TWiki” first=“Hari” last=“Sadu”}%  Dear Hari Sadu, Welcome to the world of TWiki This should get expanded to:
 
 
Database Connectivity   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Exercise ,[object Object],[object Object],[object Object],[object Object]
References ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
References (Cont…) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]

Weitere ähnliche Inhalte

Was ist angesagt?

Perl 101 - The Basics of Perl Programming
Perl  101 - The Basics of Perl ProgrammingPerl  101 - The Basics of Perl Programming
Perl 101 - The Basics of Perl ProgrammingUtkarsh Sengar
 
Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Prof. Wim Van Criekinge
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to PerlDave Cross
 
Intermediate Perl
Intermediate PerlIntermediate Perl
Intermediate PerlDave Cross
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl TechniquesDave Cross
 
Introduction to Perl Best Practices
Introduction to Perl Best PracticesIntroduction to Perl Best Practices
Introduction to Perl Best PracticesJosé Castro
 
Improving Dev Assistant
Improving Dev AssistantImproving Dev Assistant
Improving Dev AssistantDave Cross
 
Introducing Modern Perl
Introducing Modern PerlIntroducing Modern Perl
Introducing Modern PerlDave Cross
 
DBIx::Class introduction - 2010
DBIx::Class introduction - 2010DBIx::Class introduction - 2010
DBIx::Class introduction - 2010leo lapworth
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.VimLin Yo-An
 

Was ist angesagt? (20)

Perl 101 - The Basics of Perl Programming
Perl  101 - The Basics of Perl ProgrammingPerl  101 - The Basics of Perl Programming
Perl 101 - The Basics of Perl Programming
 
Intro to Perl and Bioperl
Intro to Perl and BioperlIntro to Perl and Bioperl
Intro to Perl and Bioperl
 
Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Intermediate Perl
Intermediate PerlIntermediate Perl
Intermediate Perl
 
Perl
PerlPerl
Perl
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl Techniques
 
Introduction to Perl Best Practices
Introduction to Perl Best PracticesIntroduction to Perl Best Practices
Introduction to Perl Best Practices
 
Introduction to Perl and BioPerl
Introduction to Perl and BioPerlIntroduction to Perl and BioPerl
Introduction to Perl and BioPerl
 
Perl tutorial
Perl tutorialPerl tutorial
Perl tutorial
 
Improving Dev Assistant
Improving Dev AssistantImproving Dev Assistant
Improving Dev Assistant
 
Introducing Modern Perl
Introducing Modern PerlIntroducing Modern Perl
Introducing Modern Perl
 
Working with text, Regular expressions
Working with text, Regular expressionsWorking with text, Regular expressions
Working with text, Regular expressions
 
Perl Basics with Examples
Perl Basics with ExamplesPerl Basics with Examples
Perl Basics with Examples
 
Subroutines
SubroutinesSubroutines
Subroutines
 
DBIx::Class introduction - 2010
DBIx::Class introduction - 2010DBIx::Class introduction - 2010
DBIx::Class introduction - 2010
 
Lists and arrays
Lists and arraysLists and arrays
Lists and arrays
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
 
Scalar data types
Scalar data typesScalar data types
Scalar data types
 
Perl Programming - 02 Regular Expression
Perl Programming - 02 Regular ExpressionPerl Programming - 02 Regular Expression
Perl Programming - 02 Regular Expression
 

Ähnlich wie Perl Presentation

Beginning Perl
Beginning PerlBeginning Perl
Beginning PerlDave Cross
 
CGI With Object Oriented Perl
CGI With Object Oriented PerlCGI With Object Oriented Perl
CGI With Object Oriented PerlBunty Ray
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In PerlKang-min Liu
 
Why Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, MarakanaWhy Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, MarakanaMarko Gargenta
 
PERL Unit 6 regular expression
PERL Unit 6 regular expressionPERL Unit 6 regular expression
PERL Unit 6 regular expressionBinsent Ribera
 
Introduction to Modern Perl
Introduction to Modern PerlIntroduction to Modern Perl
Introduction to Modern PerlDave Cross
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottO'Reilly Media
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Languagezone
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoobirbal
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming LanguageRaghavan Mohan
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de JavascriptBernard Loire
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisIan Macali
 
Talk Unix Shell Script
Talk Unix Shell ScriptTalk Unix Shell Script
Talk Unix Shell ScriptDr.Ravi
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Andrea Telatin
 

Ähnlich wie Perl Presentation (20)

Beginning Perl
Beginning PerlBeginning Perl
Beginning Perl
 
CGI With Object Oriented Perl
CGI With Object Oriented PerlCGI With Object Oriented Perl
CGI With Object Oriented Perl
 
Cleancode
CleancodeCleancode
Cleancode
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
Why Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, MarakanaWhy Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, Marakana
 
PERL Unit 6 regular expression
PERL Unit 6 regular expressionPERL Unit 6 regular expression
PERL Unit 6 regular expression
 
Introduction to Modern Perl
Introduction to Modern PerlIntroduction to Modern Perl
Introduction to Modern Perl
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
Javascript
JavascriptJavascript
Javascript
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de Javascript
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
Javascript
JavascriptJavascript
Javascript
 
Php2
Php2Php2
Php2
 
Talk Unix Shell Script
Talk Unix Shell ScriptTalk Unix Shell Script
Talk Unix Shell Script
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Prototype js
Prototype jsPrototype js
Prototype js
 

Kürzlich hochgeladen

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Kürzlich hochgeladen (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

Perl Presentation

  • 1. Perl Sopan Shewale, [email_address]
  • 2. Hello World – First Program $ cat HelloWorld.pl #!/usr/bin/perl print &quot;Welcome to the world of Perl Programming !&quot;; $ chmod +x HelloWorld.pl $ ./HelloWorld.pl Welcome to the world of Perl Programming ! $ perl HelloWorld.pl Welcome to the world of Perl Programming ! Make it executable Execute it Another Way to Execute
  • 3. Another Simple Example – Taking input from user [sopan@ps3724 tutorial]$ cat InteractiveHello.pl #!/usr/bin/perl my $user; print &quot;Please write your name:&quot;; $user = <STDIN>; print &quot;Welcome to the world of perl, You are : $user&quot;;
  • 4. Simple example – way to execute external command [sopan@ps3724 tutorial]$ cat df.pl #!/usr/bin/perl print &quot;Method1:&quot;; my $out1 = system(&quot;df -k&quot;); print &quot;The output of df -k command is : $out1&quot;; Method1: Filesystem 1K-blocks Used Available Use% Mounted on /dev/hda8 19346964 10931664 7432528 60% / /dev/hda1 101089 14826 81044 16% /boot /dev/hda3 15116868 12328832 2020132 86% /home none 252056 0 252056 0% /dev/shm /dev/hda5 8064272 5384612 2270008 71% /usr /dev/hda6 3020140 307088 2559636 11% /var /dev/hda2 30233928 8830792 19867324 31% /usr/local The output of df -k command is : 0
  • 5. Simple example – way to execute external command print &quot;Method2:&quot;; my $out2 = `df -k`; print &quot;The output of df -k command is : $out2&quot;; Method2: The output of df -k command is : Filesystem 1K-blocks Used Available Use% Mounted on /dev/hda8 19346964 10931664 7432528 60% / /dev/hda1 101089 14826 81044 16% /boot /dev/hda3 15116868 12328832 2020132 86% /home none 252056 0 252056 0% /dev/shm /dev/hda5 8064272 5384612 2270008 71% /usr /dev/hda6 3020140 307088 2559636 11% /var /dev/hda2 30233928 8830792 19867324 31% /usr/local [sopan@ps3724 tutorial]$
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. Regular expression (Cont…) Let us look at the example if (&quot;Hello World &quot; =~ /World/) { print &quot;It matches&quot;; } else { print &quot;It doesn't match&quot;; } The sense of =~ is reversed by !~ operator.
  • 15. Regular Expression (Cont…) The literal string in the regexp can be replaced by a variable: $greeting = &quot;World&quot;; if (&quot;Hello World&quot; =~ /$greeting/) { print &quot;It matches&quot;; } else { print &quot;It doesn't match&quot;; } Regexp’s are case sensitive
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23. [1]. Start with the first letter in the string 'a'. [2]. Try the first alternative in the first group 'abd'. [3]. Match 'a' followed by 'b'. So far so good. [4]. 'd' in the regexp doesn't match 'c' in the string – a dead end. So backtrack two characters and pick the second alternative in the first group 'abc'. [5]. Match 'a' followed by 'b' followed by 'c'. We are on a roll and have satisfied the first group. Set $1 to 'abc'. [6]. Move on to the second group and pick the first alternative 'df'. [7]. Match the 'd'. [8]. 'f' in the regexp doesn't match 'e' in the string, so a dead end. Backtrack one character and pick the second alternative in the second group 'd'. [9]. 'd' matches. The second grouping is satisfied, so set $2 to 'd'. [10]. We are at the end of the regexp, so we are done! We have matched 'abcd' out of the string &quot;abcde&quot;. Regular Expression (Cont…)
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33. References # Create some variables $a = &quot;mama mia&quot;; @array = (10, 20); %hash = (&quot;laurel&quot; => &quot;hardy&quot;, &quot;nick&quot; => &quot;nora&quot;); # Now create references to them $ra = a; # $ra now &quot;refers&quot; to (points to) $a $rarray = array; $rhash = hash; #You can create references to constant scalars in a similar fashion: $ra = 0; $rs = amp;quot;hello world&quot;;
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.  
  • 39.
  • 40.
  • 41.  
  • 42.
  • 43.  
  • 44.
  • 45. Example: Count Click Script #!/usr/bin/perl ######################### ## Author: Sopan Shewale ## Company: Persistent Systems Pvt Ltd ## This script is created for giving demo on click count. ## The Script is support to display increse/decrease ##click's, handles back button of browser, does not ##handle reload stuff. ## also it's based on sessions. ######################## use strict; use warnings; use CGI; use CGI::Session; use CGI::Cookie; my $q = new CGI(); my $sessionid = $q->cookie(&quot;CGISESSID&quot;) || undef; my $session = new CGI::Session(undef, $sessionid, {Directory=>'/tmp'}); $sessionid = $session->id(); my $cookie = new CGI::Cookie(-name=>'CGISESSID', -value=>$sessionid, -path=>&quot;/&quot;); print $q->header('text/html', -cookie=>$cookie); print $q->start_html(&quot;Welcome to Click Count Demo&quot;); print &quot;<h1>Welcome to Click Count Demo</h1>&quot;; my $count = $session->param('count'); ## count-is click count variable if(!defined($count)) { $session->param('count', 0); $count=0;} ### if session is first time created, set count=0 $session->param('count', $count); $count = $session->param('count'); #print &quot;<h1>The Click Count is: $count &quot;; ## Form stuff print $q->startform(-method=>'POST'); print $q->submit( -name=>&quot;Increase&quot;, -value=>'Increase1'); print $q->submit( -name=>&quot;Decrease&quot;, -value=>'Decrease1'); print $q->endform();
  • 46. Example: Count Click Script (Cont…) ## Which button is being pressed my $which_button = $q->param('Increase'); if(defined ($which_button)) { print &quot;Increase pressed&quot;; $count = increase_count($count); ## Increase the count since increase button is clicked $session->param('count', $count); }else { $which_button=$q->param('Decrease'); if(defined($which_button)){ print &quot;Decrease pressed&quot;; $count = decrease_count($count); ## Decrease the count since decrease button is clicked $session->param('count', $count); } else {print &quot;You have not pressed any button, seems you are typing/re-typing the same URL&quot;; } } $count = $session->param('count'); print &quot;<h1>The Click Count is: $count &quot;; print $q->end_html(); ## increases the count by 1 sub increase_count { my $number = shift; $number = $number +1; return $number; } ## decreases the count by 1 sub decrease_count { my $number = shift; $number = $number -1; return $number; }
  • 47.
  • 49. TWiki
  • 50. bin: view, edit, search etc tools: mailnotify template: Templates (view.tmpl), also has skin related data lib: modules and required libraries, plugin code data: webs directories (e.g. Main,TWiki) and each directory inside contains the topics from that web. The topics are companied by there version history pub: Attachments of the topics and commonly shared data
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.  
  • 57.  
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.