SlideShare une entreprise Scribd logo
1  sur  10
Perl  Programming
Topics Introduction to Perl Variables Scalars Arrays Hashes Regular Expressions
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
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 ”; First example #! C:/perl/bin/perl.exe print “Content-type: text/html ”; Print “Hello World “;
Introduction Go to the command prompt  and execute the command  perl filename.pl In the browser, type http://localhost/filename.pl
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);
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
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
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/>”;}
Regular Expression Matches a word or a phrase or even a character trying to match a pattern Meta characters Pattern Modifiers

Contenu connexe

En vedette

En vedette (9)

ShravanTamaskar_Thesis
ShravanTamaskar_ThesisShravanTamaskar_Thesis
ShravanTamaskar_Thesis
 
Industrial Networks: the Choices for Real Time Motion Control
Industrial Networks: the Choices for Real Time Motion ControlIndustrial Networks: the Choices for Real Time Motion Control
Industrial Networks: the Choices for Real Time Motion Control
 
Ether cat introduction_pt
Ether cat introduction_ptEther cat introduction_pt
Ether cat introduction_pt
 
Kernel Recipes 2014 - Testing Video4Linux Applications and Drivers
Kernel Recipes 2014 - Testing Video4Linux Applications and DriversKernel Recipes 2014 - Testing Video4Linux Applications and Drivers
Kernel Recipes 2014 - Testing Video4Linux Applications and Drivers
 
Device drivers tsp
Device drivers tspDevice drivers tsp
Device drivers tsp
 
Kernel Recipes 2013 - Overview display in the Linux kernel
Kernel Recipes 2013 - Overview display in the Linux kernelKernel Recipes 2013 - Overview display in the Linux kernel
Kernel Recipes 2013 - Overview display in the Linux kernel
 
Design and development of MIL-STD-1553 based engineering model
Design and development of MIL-STD-1553 based engineering modelDesign and development of MIL-STD-1553 based engineering model
Design and development of MIL-STD-1553 based engineering model
 
Software Defined Networking - 2
Software Defined Networking - 2Software Defined Networking - 2
Software Defined Networking - 2
 
Software Defined Networking - 1
Software Defined Networking - 1Software Defined Networking - 1
Software Defined Networking - 1
 

Similaire à Perl programming tsp

Using Unix
Using UnixUsing Unix
Using Unix
Dr.Ravi
 

Similaire à Perl programming tsp (20)

Perl
PerlPerl
Perl
 
Perl Basics with Examples
Perl Basics with ExamplesPerl Basics with Examples
Perl Basics with Examples
 
Introduction to perl_ a scripting language
Introduction to perl_ a scripting languageIntroduction to perl_ a scripting language
Introduction to perl_ a scripting language
 
Unit 1-introduction to perl
Unit 1-introduction to perlUnit 1-introduction to perl
Unit 1-introduction to perl
 
perl lauange
perl lauangeperl lauange
perl lauange
 
Pearl
PearlPearl
Pearl
 
Learn PERL at ASIT
Learn PERL at ASITLearn PERL at ASIT
Learn PERL at ASIT
 
390aLecture05_12sp.ppt
390aLecture05_12sp.ppt390aLecture05_12sp.ppt
390aLecture05_12sp.ppt
 
Using Unix
Using UnixUsing Unix
Using Unix
 
Perl bhargav
Perl bhargavPerl bhargav
Perl bhargav
 
Introduction to Modern Perl
Introduction to Modern PerlIntroduction to Modern Perl
Introduction to Modern Perl
 
Day1
Day1Day1
Day1
 
Intro to Perl
Intro to PerlIntro to Perl
Intro to Perl
 
Choosing a Templating System
Choosing a Templating SystemChoosing a Templating System
Choosing a Templating System
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Introduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable PerlIntroduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable Perl
 
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
 
Perl Reference.ppt
Perl Reference.pptPerl Reference.ppt
Perl Reference.ppt
 
Php a dynamic web scripting language
Php   a dynamic web scripting languagePhp   a dynamic web scripting language
Php a dynamic web scripting language
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 

Plus de Pradeep Kumar TS

Plus de Pradeep Kumar TS (20)

Digital Portfolio and Footprint
Digital Portfolio and FootprintDigital Portfolio and Footprint
Digital Portfolio and Footprint
 
Open book Examination
Open book ExaminationOpen book Examination
Open book Examination
 
Software Define Networking (SDN)
Software Define Networking (SDN)Software Define Networking (SDN)
Software Define Networking (SDN)
 
What next - Career Enhancement of Graduates
What next - Career Enhancement of GraduatesWhat next - Career Enhancement of Graduates
What next - Career Enhancement of Graduates
 
Protothreads
ProtothreadsProtothreads
Protothreads
 
6LoWPAN
6LoWPAN 6LoWPAN
6LoWPAN
 
Software Defined Networks
Software Defined NetworksSoftware Defined Networks
Software Defined Networks
 
Higher Order Thinking - Question paper setting
Higher Order Thinking - Question paper settingHigher Order Thinking - Question paper setting
Higher Order Thinking - Question paper setting
 
IoT Communication Protocols
IoT Communication ProtocolsIoT Communication Protocols
IoT Communication Protocols
 
IoT Applications
IoT ApplicationsIoT Applications
IoT Applications
 
RPL - Routing Protocol for Low Power and Lossy Networks
RPL - Routing Protocol for Low Power and Lossy NetworksRPL - Routing Protocol for Low Power and Lossy Networks
RPL - Routing Protocol for Low Power and Lossy Networks
 
Mannasim for NS2
Mannasim for NS2Mannasim for NS2
Mannasim for NS2
 
Recompiling network simulator 2
Recompiling network simulator 2Recompiling network simulator 2
Recompiling network simulator 2
 
OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2
 
Wired and Wireless Examples in ns2
Wired and Wireless Examples in ns2Wired and Wireless Examples in ns2
Wired and Wireless Examples in ns2
 
Installation of ns2
Installation of ns2Installation of ns2
Installation of ns2
 
Introduction to ns2
Introduction to ns2Introduction to ns2
Introduction to ns2
 
Software Defined Networking - 3
Software Defined Networking - 3Software Defined Networking - 3
Software Defined Networking - 3
 
Tracing and awk in ns2
Tracing and awk in ns2Tracing and awk in ns2
Tracing and awk in ns2
 
Virtual classrooms and labs using Big Blue Button
Virtual classrooms and labs using Big Blue ButtonVirtual classrooms and labs using Big Blue Button
Virtual classrooms and labs using Big Blue Button
 

Dernier

Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Dernier (20)

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

Perl programming tsp

  • 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 ”; First example #! C:/perl/bin/perl.exe print “Content-type: text/html ”; 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