SlideShare a Scribd company logo
Perl
A STEP UP FROM BASH
Perl’s Creator: Larry Wall
• LarryWall, programmer, linguist, author, born March 10, 1949 in
Duncan, British Columbia, Canada. Perl computer language creation
in 1987.
• Quotes:
• The three chief virtues of a programmer are: Laziness, Impatience and Hubris
• There's MoreThan OneWay to Do It
• Add your first bullet point here
• Add your second bullet point here
• Add your third bullet point here
What is Perl
 Practical Extraction and Reporting Language
 Pathologically Eclectic Rubbish Lister
 “Perl” is the language
 “perl” is the compiler
 Never “PERL”
• Perl is a general-purpose programming language originally developed for text manipulation and
now used for a wide range of tasks including web development, system administration, network
programming, code generation and more.
• It's intended to be practical rather than beautiful.
• Supports both procedural and OO programming.
• It has one of the world's most impressive collections of third-party modules (http://www.cpan.org).
The Perl philosophy
• There’s more than one way to do it.
• Share and Enjoy!
• General Purpose Programming Language
• Open Source
• Fast
• Flexible
• Secure
• Fun
• Cross Plaform
• Large active user base
• Can look complicated, initially, particularly if you're not familiar with regular
expressions
Interpreting Perl
• In a File
• print “This is AWESOMMMMMEEEEEEEE!n”;
• On command line: perl script.pl
• #!/usr/bin/perl
• print “This is AWESOMMMMMEEEEEEEE!n”;
• On Command line ./script.pl
• On the shell
• perl –e ‘print “This is AWWEESSSOOMMEEEEEn” ’
Perl Syntax Overview
• White space is ignored
• Perl statements end with a semi-
colon.
print ("Hello, world!");
• Comments start with a # and run to
the end of the line.
# This is a comment
• Double quotes or single quotes may
be used around literal strings:
print("Hello, world!");
print ('Hello, world!');
• However, only double quotes
interpolate variables and special
characters such as newlines (n):
• Scalar variables start with a $
• Question: What is a scalar value?
• “ ”
• ‘ ’
• 42
• .0001
• 3.27e17
• Perl will automatically convert
between types as required.
• print('3' + 4.5); # prints
7.5
• Concatenation:Arithmetic operators
Vs.
.
Time Out to Code
Unique to Perl
PRAGMAS
• Perl is a permissive language
• A way to impose discipline is
with pragmas.
• A pragma is a directive to the
interpreter informing it about
some form of I/O with the code.
• use warnings; # display warnings
• use strict; #more restrictive to
assist in identification of mistakes
SPECIAL VARIABLES
• There are some ‘magic’ variables.
These special variables are used for all
kinds of purposes.
• $_: is the ‘default variable’.
• @ARGV: the command line arguments to
your script.
• $ARGV: contains the name of the current
file when reading from <> or
readline().
• @_: the arguments passed to a
subroutine.
• $a, $b: Special package variables when
using sort().
• $/:The input record separator, newline
by default.
Conditional Constructs
• The COND shall be conditional statement
surround by ( and ), and BLOCK shall be
one ore more statements surround by {
and }.
• if ( is_valid( $value ) )
{ … }
elsif (cond)
{ ...}
else
{ ...}
• Ex.
if ($zippy)
{
print("Yow!");
}
Arithmetic and String Operators
ARITHMETIC OPERATORS
 Standard arithmetic operations
 Less standard operations
modulus (%), exponentiation (**)
 $area = $pi * ($radius ** 2);
 Often need to do things like
$total = $total + $amount;
 Can be abbreviated to
$total += $amount;
 Even shorter
 $x++;
 $y--;
 Question:What is the subtle
difference between $x++ and ++$x?
STRING OPERATORS
 Concaternation (.)
 $name = $firstname . ' ' .
$surname;
 Repetition (x)
 $line = '-' x 80;
$police = 'hello ' x 3;
 Shortcut versions available
 $page .= $line; # $page
= $page . $line
 $thing x= $i; #
$thing = $thing x $i

More Related Content

What's hot

Ruby 1.9.3 Basic Introduction
Ruby 1.9.3 Basic IntroductionRuby 1.9.3 Basic Introduction
Ruby 1.9.3 Basic Introduction
Prabu D
 

What's hot (20)

Arrays &amp; functions in php
Arrays &amp; functions in phpArrays &amp; functions in php
Arrays &amp; functions in php
 
Introduction To Power Shell
Introduction To Power ShellIntroduction To Power Shell
Introduction To Power Shell
 
Introduction in php part 2
Introduction in php part 2Introduction in php part 2
Introduction in php part 2
 
Beautiful Bash: Let's make reading and writing bash scripts fun again!
Beautiful Bash: Let's make reading and writing bash scripts fun again!Beautiful Bash: Let's make reading and writing bash scripts fun again!
Beautiful Bash: Let's make reading and writing bash scripts fun again!
 
Functions in php
Functions in phpFunctions in php
Functions in php
 
Introduction in php
Introduction in phpIntroduction in php
Introduction in php
 
Php Chapter 2 3 Training
Php Chapter 2 3 TrainingPhp Chapter 2 3 Training
Php Chapter 2 3 Training
 
Attributes Unwrapped: Lessons under the surface of active record
Attributes Unwrapped: Lessons under the surface of active recordAttributes Unwrapped: Lessons under the surface of active record
Attributes Unwrapped: Lessons under the surface of active record
 
Introducing Ruby
Introducing RubyIntroducing Ruby
Introducing Ruby
 
Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
4.2 PHP Function
4.2 PHP Function4.2 PHP Function
4.2 PHP Function
 
Unix - Shell Scripts
Unix - Shell ScriptsUnix - Shell Scripts
Unix - Shell Scripts
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...
Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...
Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...
 
Ruby 1.9.3 Basic Introduction
Ruby 1.9.3 Basic IntroductionRuby 1.9.3 Basic Introduction
Ruby 1.9.3 Basic Introduction
 
Linux System Administration
Linux System AdministrationLinux System Administration
Linux System Administration
 
Yapc::NA::2009 - Command Line Perl
Yapc::NA::2009 - Command Line PerlYapc::NA::2009 - Command Line Perl
Yapc::NA::2009 - Command Line Perl
 
Cleancode
CleancodeCleancode
Cleancode
 
Moose
MooseMoose
Moose
 

Similar to Intro to Perl

BASH Guide Summary
BASH Guide SummaryBASH Guide Summary
BASH Guide Summary
Ohgyun Ahn
 
Bash shell
Bash shellBash shell
Bash shell
xylas121
 
MIND sweeping introduction to PHP
MIND sweeping introduction to PHPMIND sweeping introduction to PHP
MIND sweeping introduction to PHP
BUDNET
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
pooja bhandari
 

Similar to Intro to Perl (20)

Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013
 
BASH Guide Summary
BASH Guide SummaryBASH Guide Summary
BASH Guide Summary
 
Bash shell
Bash shellBash shell
Bash shell
 
Learn perl in amc square learning
Learn perl in amc square learningLearn perl in amc square learning
Learn perl in amc square learning
 
Bioinformatics v2014 wim_vancriekinge
Bioinformatics v2014 wim_vancriekingeBioinformatics v2014 wim_vancriekinge
Bioinformatics v2014 wim_vancriekinge
 
390aLecture05_12sp.ppt
390aLecture05_12sp.ppt390aLecture05_12sp.ppt
390aLecture05_12sp.ppt
 
MIND sweeping introduction to PHP
MIND sweeping introduction to PHPMIND sweeping introduction to PHP
MIND sweeping introduction to PHP
 
Intro to Perl and Bioperl
Intro to Perl and BioperlIntro to Perl and Bioperl
Intro to Perl and Bioperl
 
05php
05php05php
05php
 
php fundamental
php fundamentalphp fundamental
php fundamental
 
php
phpphp
php
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
 
Scripting and the shell in LINUX
Scripting and the shell in LINUXScripting and the shell in LINUX
Scripting and the shell in LINUX
 
Php basics
Php basicsPhp basics
Php basics
 
Perl bhargav
Perl bhargavPerl bhargav
Perl bhargav
 
Php classes in mumbai
Php classes in mumbaiPhp classes in mumbai
Php classes in mumbai
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Perl
PerlPerl
Perl
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010
 
Perl Basics with Examples
Perl Basics with ExamplesPerl Basics with Examples
Perl Basics with Examples
 

More from primeteacher32

More from primeteacher32 (20)

Software Development Life Cycle
Software Development Life CycleSoftware Development Life Cycle
Software Development Life Cycle
 
Variable Scope
Variable ScopeVariable Scope
Variable Scope
 
Returning Data
Returning DataReturning Data
Returning Data
 
Intro to Functions
Intro to FunctionsIntro to Functions
Intro to Functions
 
Introduction to GUIs with guizero
Introduction to GUIs with guizeroIntroduction to GUIs with guizero
Introduction to GUIs with guizero
 
Function Parameters
Function ParametersFunction Parameters
Function Parameters
 
Nested Loops
Nested LoopsNested Loops
Nested Loops
 
Conditional Loops
Conditional LoopsConditional Loops
Conditional Loops
 
Introduction to Repetition Structures
Introduction to Repetition StructuresIntroduction to Repetition Structures
Introduction to Repetition Structures
 
Input Validation
Input ValidationInput Validation
Input Validation
 
Windows File Systems
Windows File SystemsWindows File Systems
Windows File Systems
 
Nesting Conditionals
Nesting ConditionalsNesting Conditionals
Nesting Conditionals
 
Conditionals
ConditionalsConditionals
Conditionals
 
Intro to Python with GPIO
Intro to Python with GPIOIntro to Python with GPIO
Intro to Python with GPIO
 
Variables and Statements
Variables and StatementsVariables and Statements
Variables and Statements
 
Variables and User Input
Variables and User InputVariables and User Input
Variables and User Input
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
 
Hardware vs. Software Presentations
Hardware vs. Software PresentationsHardware vs. Software Presentations
Hardware vs. Software Presentations
 
Block chain security
Block chain securityBlock chain security
Block chain security
 

Recently uploaded

Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Dirk Spencer Corporate Recruiter LION
 
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
larisashrestha558
 

Recently uploaded (20)

129. Reviewer Certificate in BioNature [2024]
129. Reviewer Certificate in BioNature [2024]129. Reviewer Certificate in BioNature [2024]
129. Reviewer Certificate in BioNature [2024]
 
How to create an effective K-POC tutorial
How to create an effective K-POC tutorialHow to create an effective K-POC tutorial
How to create an effective K-POC tutorial
 
0524.priorspeakingengagementslist-01.pdf
0524.priorspeakingengagementslist-01.pdf0524.priorspeakingengagementslist-01.pdf
0524.priorspeakingengagementslist-01.pdf
 
Luke Royak's Personal Brand Exploration!
Luke Royak's Personal Brand Exploration!Luke Royak's Personal Brand Exploration!
Luke Royak's Personal Brand Exploration!
 
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
Transferable Skills - Your Roadmap - Part 1 and 2 - Dirk Spencer Senior Recru...
 
欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】
欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】
欧洲杯投注app-欧洲杯投注app推荐-欧洲杯投注app| 立即访问【ac123.net】
 
D.El.Ed. College List -Session 2024-26.pdf
D.El.Ed. College List -Session 2024-26.pdfD.El.Ed. College List -Session 2024-26.pdf
D.El.Ed. College List -Session 2024-26.pdf
 
132. Acta Scientific Pharmaceutical Sciences
132. Acta Scientific Pharmaceutical Sciences132. Acta Scientific Pharmaceutical Sciences
132. Acta Scientific Pharmaceutical Sciences
 
Midterm Contract Law and Adminstration.pptx
Midterm Contract Law and Adminstration.pptxMidterm Contract Law and Adminstration.pptx
Midterm Contract Law and Adminstration.pptx
 
131. Reviewer Certificate in BP International
131. Reviewer Certificate in BP International131. Reviewer Certificate in BP International
131. Reviewer Certificate in BP International
 
太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】
太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】
太阳城娱乐-太阳城娱乐推荐-太阳城娱乐官方网站| 立即访问【ac123.net】
 
0524.THOMASGIRARD_CURRICULUMVITAE-01.pdf
0524.THOMASGIRARD_CURRICULUMVITAE-01.pdf0524.THOMASGIRARD_CURRICULUMVITAE-01.pdf
0524.THOMASGIRARD_CURRICULUMVITAE-01.pdf
 
134. Reviewer Certificate in Computer Science
134. Reviewer Certificate in Computer Science134. Reviewer Certificate in Computer Science
134. Reviewer Certificate in Computer Science
 
欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】
欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】
欧洲杯投注网站-欧洲杯投注网站推荐-欧洲杯投注网站| 立即访问【ac123.net】
 
DIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptxDIGITAL MARKETING COURSE IN CHENNAI.pptx
DIGITAL MARKETING COURSE IN CHENNAI.pptx
 
How to Master LinkedIn for Career and Business
How to Master LinkedIn for Career and BusinessHow to Master LinkedIn for Career and Business
How to Master LinkedIn for Career and Business
 
Operating system. short answes and Interview questions .pdf
Operating system. short answes and Interview questions .pdfOperating system. short answes and Interview questions .pdf
Operating system. short answes and Interview questions .pdf
 
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
皇冠体育- 皇冠体育官方网站- CROWN SPORTS| 立即访问【ac123.net】
 
Day care leadership document it helps to a person who needs caring children
Day care leadership document it helps to a person who needs caring childrenDay care leadership document it helps to a person who needs caring children
Day care leadership document it helps to a person who needs caring children
 
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR GeneralistHeidi Livengood Resume Senior Technical Recruiter / HR Generalist
Heidi Livengood Resume Senior Technical Recruiter / HR Generalist
 

Intro to Perl

  • 1. Perl A STEP UP FROM BASH
  • 2. Perl’s Creator: Larry Wall • LarryWall, programmer, linguist, author, born March 10, 1949 in Duncan, British Columbia, Canada. Perl computer language creation in 1987. • Quotes: • The three chief virtues of a programmer are: Laziness, Impatience and Hubris • There's MoreThan OneWay to Do It • Add your first bullet point here • Add your second bullet point here • Add your third bullet point here
  • 3. What is Perl  Practical Extraction and Reporting Language  Pathologically Eclectic Rubbish Lister  “Perl” is the language  “perl” is the compiler  Never “PERL” • Perl is a general-purpose programming language originally developed for text manipulation and now used for a wide range of tasks including web development, system administration, network programming, code generation and more. • It's intended to be practical rather than beautiful. • Supports both procedural and OO programming. • It has one of the world's most impressive collections of third-party modules (http://www.cpan.org).
  • 4. The Perl philosophy • There’s more than one way to do it. • Share and Enjoy! • General Purpose Programming Language • Open Source • Fast • Flexible • Secure • Fun • Cross Plaform • Large active user base • Can look complicated, initially, particularly if you're not familiar with regular expressions
  • 5. Interpreting Perl • In a File • print “This is AWESOMMMMMEEEEEEEE!n”; • On command line: perl script.pl • #!/usr/bin/perl • print “This is AWESOMMMMMEEEEEEEE!n”; • On Command line ./script.pl • On the shell • perl –e ‘print “This is AWWEESSSOOMMEEEEEn” ’
  • 6. Perl Syntax Overview • White space is ignored • Perl statements end with a semi- colon. print ("Hello, world!"); • Comments start with a # and run to the end of the line. # This is a comment • Double quotes or single quotes may be used around literal strings: print("Hello, world!"); print ('Hello, world!'); • However, only double quotes interpolate variables and special characters such as newlines (n): • Scalar variables start with a $ • Question: What is a scalar value? • “ ” • ‘ ’ • 42 • .0001 • 3.27e17 • Perl will automatically convert between types as required. • print('3' + 4.5); # prints 7.5 • Concatenation:Arithmetic operators Vs. .
  • 7. Time Out to Code
  • 8. Unique to Perl PRAGMAS • Perl is a permissive language • A way to impose discipline is with pragmas. • A pragma is a directive to the interpreter informing it about some form of I/O with the code. • use warnings; # display warnings • use strict; #more restrictive to assist in identification of mistakes SPECIAL VARIABLES • There are some ‘magic’ variables. These special variables are used for all kinds of purposes. • $_: is the ‘default variable’. • @ARGV: the command line arguments to your script. • $ARGV: contains the name of the current file when reading from <> or readline(). • @_: the arguments passed to a subroutine. • $a, $b: Special package variables when using sort(). • $/:The input record separator, newline by default.
  • 9. Conditional Constructs • The COND shall be conditional statement surround by ( and ), and BLOCK shall be one ore more statements surround by { and }. • if ( is_valid( $value ) ) { … } elsif (cond) { ...} else { ...} • Ex. if ($zippy) { print("Yow!"); }
  • 10. Arithmetic and String Operators ARITHMETIC OPERATORS  Standard arithmetic operations  Less standard operations modulus (%), exponentiation (**)  $area = $pi * ($radius ** 2);  Often need to do things like $total = $total + $amount;  Can be abbreviated to $total += $amount;  Even shorter  $x++;  $y--;  Question:What is the subtle difference between $x++ and ++$x? STRING OPERATORS  Concaternation (.)  $name = $firstname . ' ' . $surname;  Repetition (x)  $line = '-' x 80; $police = 'hello ' x 3;  Shortcut versions available  $page .= $line; # $page = $page . $line  $thing x= $i; # $thing = $thing x $i

Editor's Notes

  1. Strict enforces that variables begin with a my so it can identify when variables have not been declared. Variables can be created whenever in a script and sometimes by accident, like with files in Linux, so to enforce a stricter policy use the strict pragma and now you have to declare variables with a my or it will notify you that a variable has not been declared.