SlideShare a Scribd company logo
1 of 23
Perl  簡介 Sway   2010/12/28
equals(  ,  ) Cross-platform, open-source, scripting language,  multi-paradigm, dynamic typing, statement ratio: 6 There should be one way There’s more than one way Guido van Rossum Larry Wall 1991 1987 Python Perl Easy Difficult
Perl  特色 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CPAN ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
you must be joking! http://www.strombergers.com/python/ my @list = ('a', 'b', 'c');  my %hash;  $hash{‘letters'} = list;  print "@{$hash{‘letters'}}";   list = ['a', 'b', 'c']  hash = {}  hash[‘letters'] = list  print hash[‘letters']   package Person;  use strict;  sub new {  my $class = shift;  my $age = shift or die "Must pass age";  my $rSelf = {'age' => $age};  bless ($rSelf, $class);  return $rSelf;  }   class Person:  def __init__(self, age):  self.age = age   @list = ( [‘a’, ’b’, ’c’], [1, 2, 3] ); print “@{$list[0]}”;  list = [ [‘a’, ’b’, ’c’], [1, 2, 3] ] print list[0]
More Perl bashing… http://www.strombergers.com/python/ sub add { $_[0] + $_[1];  }   def add(a, b): return a + b sub add { my ($a, $b) = _@;  return $a + $b;  }   sub add { my $a = shift; my $b = shift; return $a + $b;  }   def diff(a, b): return len(a) - len(b) sub diff { my ($aref, $bref) = _@; my (@a) = @$aref;  my (@b) = @$bref;   return scalar(@a) + scalar(@b); } sub add($, $) { local ($a, $b) = _@;  return $a + $b;  }
More Perl…
  CGI Perl is widely used for web programming
Perl Syntax ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
one of ten Perl myths http://www.perl.com/pub/a/2000/01/10PerlMyths.html “… Perl works the way you do…”   “… That's one, fairly natural way to think about it…”   while (<>) {  s/(.*):(.*)/$2:$1/;  print;  }   Swap two sections of a string: “aaa:bbb” -> “bbb:aaa”   for line in file: line = line.strip() first, second = line.split(‘:’) print second+’:’+first while (<>) {  chomp;  ($first, $second) = split /:/;  print $second, &quot;:&quot;, $first, &quot;&quot;;  }   “… we can happily consign the idea that ‘Perl is hard’ to mythology.”   from re import sub for line in file: print sub(‘(.*):(.*)’, r’:’, line)
Scalars ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Arrays ,[object Object],[object Object],[object Object]
Hashes ,[object Object],[object Object],[object Object],[object Object],[object Object]
Complex data types ,[object Object],[object Object],[object Object],[object Object]
Complex data types   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Comparison ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pattern Matching ,[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]
Conditional constructs ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Conditional constructs
Looping constructs ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Looping constructs
Subroutines ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Perl 6 ,[object Object]

More Related Content

What's hot

What's hot (20)

Python
PythonPython
Python
 
Wx::Perl::Smart
Wx::Perl::SmartWx::Perl::Smart
Wx::Perl::Smart
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Functional Programming in PHP
Functional Programming in PHPFunctional Programming in PHP
Functional Programming in PHP
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
 
Unit vii wp ppt
Unit vii wp pptUnit vii wp ppt
Unit vii wp ppt
 
Unit 1-array,lists and hashes
Unit 1-array,lists and hashesUnit 1-array,lists and hashes
Unit 1-array,lists and hashes
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
How to write code you won't hate tomorrow
How to write code you won't hate tomorrowHow to write code you won't hate tomorrow
How to write code you won't hate tomorrow
 
Neatly folding-a-tree
Neatly folding-a-treeNeatly folding-a-tree
Neatly folding-a-tree
 
Write Your Own Compiler in 24 Hours
Write Your Own Compiler in 24 HoursWrite Your Own Compiler in 24 Hours
Write Your Own Compiler in 24 Hours
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Context
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string library
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
 
Go a crash course
Go   a crash courseGo   a crash course
Go a crash course
 
F# intro
F# introF# intro
F# intro
 

Viewers also liked

www.makidance.com
www.makidance.comwww.makidance.com
www.makidance.com
maki
 
Description of the earth
Description of the earthDescription of the earth
Description of the earth
pavopavo
 

Viewers also liked (19)

Formation Responsable ecommerce
Formation Responsable ecommerceFormation Responsable ecommerce
Formation Responsable ecommerce
 
Deber 1 Gabriela Bermúdez
Deber 1 Gabriela BermúdezDeber 1 Gabriela Bermúdez
Deber 1 Gabriela Bermúdez
 
Sample Analyze123 Google Analytics Report (Premium)
Sample Analyze123 Google Analytics Report (Premium)Sample Analyze123 Google Analytics Report (Premium)
Sample Analyze123 Google Analytics Report (Premium)
 
Magnolia's Magnificent Adventure
Magnolia's Magnificent AdventureMagnolia's Magnificent Adventure
Magnolia's Magnificent Adventure
 
Tears of a Woman
Tears of a WomanTears of a Woman
Tears of a Woman
 
Formation clé du-ecommerce dans l'immobilier
Formation clé du-ecommerce dans l'immobilier Formation clé du-ecommerce dans l'immobilier
Formation clé du-ecommerce dans l'immobilier
 
www.makidance.com
www.makidance.comwww.makidance.com
www.makidance.com
 
MCU compare
MCU compareMCU compare
MCU compare
 
Shantosh Bhatt CV
Shantosh Bhatt CV Shantosh Bhatt CV
Shantosh Bhatt CV
 
Plantilla presentación
Plantilla presentaciónPlantilla presentación
Plantilla presentación
 
Hong Kong PhD Fellowships 2016/17
Hong Kong PhD Fellowships 2016/17Hong Kong PhD Fellowships 2016/17
Hong Kong PhD Fellowships 2016/17
 
Formation "clé du-ecommerce"
Formation "clé du-ecommerce"Formation "clé du-ecommerce"
Formation "clé du-ecommerce"
 
Formation e-tourisme en ligne
Formation e-tourisme en ligneFormation e-tourisme en ligne
Formation e-tourisme en ligne
 
Description of the earth
Description of the earthDescription of the earth
Description of the earth
 
Domselaar GMI8 Beijing Canadian WGS Surveillance Experience
Domselaar GMI8 Beijing Canadian WGS Surveillance ExperienceDomselaar GMI8 Beijing Canadian WGS Surveillance Experience
Domselaar GMI8 Beijing Canadian WGS Surveillance Experience
 
CICD by Teerapat
CICD by TeerapatCICD by Teerapat
CICD by Teerapat
 
Docker, Continuous Integration, and You
Docker, Continuous Integration, and YouDocker, Continuous Integration, and You
Docker, Continuous Integration, and You
 
Caption story project
Caption story projectCaption story project
Caption story project
 
Entidades financieras sometidas a la supervisión de la
Entidades financieras sometidas a la supervisión de laEntidades financieras sometidas a la supervisión de la
Entidades financieras sometidas a la supervisión de la
 

Similar to Introduction to Perl

Perl training-in-navi mumbai
Perl training-in-navi mumbaiPerl training-in-navi mumbai
Perl training-in-navi mumbai
vibrantuser
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
Kang-min Liu
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
Kang-min Liu
 
Introduction to Perl - Day 2
Introduction to Perl - Day 2Introduction to Perl - Day 2
Introduction to Perl - Day 2
Dave Cross
 

Similar to Introduction to Perl (20)

Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Perl training-in-navi mumbai
Perl training-in-navi mumbaiPerl training-in-navi mumbai
Perl training-in-navi mumbai
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
You Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager NeedsYou Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager Needs
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
First steps in PERL
First steps in PERLFirst steps in PERL
First steps in PERL
 
Perl Introduction
Perl IntroductionPerl Introduction
Perl Introduction
 
Perl Presentation
Perl PresentationPerl Presentation
Perl Presentation
 
Learning Perl 6
Learning Perl 6 Learning Perl 6
Learning Perl 6
 
Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01
 
Cleancode
CleancodeCleancode
Cleancode
 
Learning Perl 6 (NPW 2007)
Learning Perl 6 (NPW 2007)Learning Perl 6 (NPW 2007)
Learning Perl 6 (NPW 2007)
 
And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressions
 
Achieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangAchieving Parsing Sanity In Erlang
Achieving Parsing Sanity In Erlang
 
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...
 
Introduction to Perl - Day 2
Introduction to Perl - Day 2Introduction to Perl - Day 2
Introduction to Perl - Day 2
 
Php & my sql
Php & my sqlPhp & my sql
Php & my sql
 
Php2
Php2Php2
Php2
 
Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.
 

More from Sway Wang (9)

Code review
Code reviewCode review
Code review
 
Refactoring
RefactoringRefactoring
Refactoring
 
Solid
SolidSolid
Solid
 
Design patterns and MV
Design patterns and MVDesign patterns and MV
Design patterns and MV
 
Duck Typing and Multiple Inheritance
Duck Typing and Multiple InheritanceDuck Typing and Multiple Inheritance
Duck Typing and Multiple Inheritance
 
How to select password(Chinese)
How to select password(Chinese)How to select password(Chinese)
How to select password(Chinese)
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Agile development
Agile developmentAgile development
Agile development
 
Libusb
LibusbLibusb
Libusb
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Introduction to Perl

  • 1. Perl 簡介 Sway 2010/12/28
  • 2. equals( , ) Cross-platform, open-source, scripting language, multi-paradigm, dynamic typing, statement ratio: 6 There should be one way There’s more than one way Guido van Rossum Larry Wall 1991 1987 Python Perl Easy Difficult
  • 3.
  • 4.
  • 5. you must be joking! http://www.strombergers.com/python/ my @list = ('a', 'b', 'c'); my %hash; $hash{‘letters'} = list; print &quot;@{$hash{‘letters'}}&quot;; list = ['a', 'b', 'c'] hash = {} hash[‘letters'] = list print hash[‘letters'] package Person; use strict; sub new { my $class = shift; my $age = shift or die &quot;Must pass age&quot;; my $rSelf = {'age' => $age}; bless ($rSelf, $class); return $rSelf; } class Person: def __init__(self, age): self.age = age @list = ( [‘a’, ’b’, ’c’], [1, 2, 3] ); print “@{$list[0]}”; list = [ [‘a’, ’b’, ’c’], [1, 2, 3] ] print list[0]
  • 6. More Perl bashing… http://www.strombergers.com/python/ sub add { $_[0] + $_[1]; } def add(a, b): return a + b sub add { my ($a, $b) = _@; return $a + $b; } sub add { my $a = shift; my $b = shift; return $a + $b; } def diff(a, b): return len(a) - len(b) sub diff { my ($aref, $bref) = _@; my (@a) = @$aref; my (@b) = @$bref; return scalar(@a) + scalar(@b); } sub add($, $) { local ($a, $b) = _@; return $a + $b; }
  • 8.   CGI Perl is widely used for web programming
  • 9.
  • 10. one of ten Perl myths http://www.perl.com/pub/a/2000/01/10PerlMyths.html “… Perl works the way you do…” “… That's one, fairly natural way to think about it…” while (<>) { s/(.*):(.*)/$2:$1/; print; } Swap two sections of a string: “aaa:bbb” -> “bbb:aaa” for line in file: line = line.strip() first, second = line.split(‘:’) print second+’:’+first while (<>) { chomp; ($first, $second) = split /:/; print $second, &quot;:&quot;, $first, &quot;&quot;; } “… we can happily consign the idea that ‘Perl is hard’ to mythology.” from re import sub for line in file: print sub(‘(.*):(.*)’, r’:’, line)
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 20.
  • 22.
  • 23.