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

PPTX
Subroutines
PPT
Introduction to perl_ a scripting language
PDF
Use the @types, Luke
PPT
php 2 Function creating, calling, PHP built-in function
PPT
Introduction to php php++
PDF
Anonymous Functions in PHP 5.3 - Matthew Weier O’Phinney
PDF
PHP Unit 3 functions_in_php_2
Subroutines
Introduction to perl_ a scripting language
Use the @types, Luke
php 2 Function creating, calling, PHP built-in function
Introduction to php php++
Anonymous Functions in PHP 5.3 - Matthew Weier O’Phinney
PHP Unit 3 functions_in_php_2

What's hot (20)

PPTX
Arrays &amp; functions in php
PPTX
Introduction To Power Shell
PPTX
Introduction in php part 2
PDF
Beautiful Bash: Let's make reading and writing bash scripts fun again!
PPT
Functions in php
PPTX
Introduction in php
PPT
Php Chapter 2 3 Training
PDF
Attributes Unwrapped: Lessons under the surface of active record
KEY
Introducing Ruby
PPTX
Object-Oriented Programming with PHP (part 1)
PDF
4.2 PHP Function
PPTX
Unix - Shell Scripts
PDF
Introduction to Ruby
PPT
Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...
PPS
Ruby 1.9.3 Basic Introduction
PPTX
Linux System Administration
PDF
Yapc::NA::2009 - Command Line Perl
PPT
Cleancode
Arrays &amp; functions in php
Introduction To Power Shell
Introduction in php part 2
Beautiful Bash: Let's make reading and writing bash scripts fun again!
Functions in php
Introduction in php
Php Chapter 2 3 Training
Attributes Unwrapped: Lessons under the surface of active record
Introducing Ruby
Object-Oriented Programming with PHP (part 1)
4.2 PHP Function
Unix - Shell Scripts
Introduction to Ruby
Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...
Ruby 1.9.3 Basic Introduction
Linux System Administration
Yapc::NA::2009 - Command Line Perl
Cleancode
Ad

Similar to Intro to Perl (20)

PPT
PERL.ppt
ODP
Beginning Perl
PPT
Introduction to perl scripting______.ppt
ODP
Introduction to Perl
PPT
Perl Programming_Guide_Document_Refr.ppt
PPT
Learn perl in amc square learning
PPT
PERL - complete_Training_Modules_Ref.ppt
PPT
PERL - complete_guide_references (1).ppt
PPT
Perl Basics with Examples
PDF
newperl5
PDF
newperl5
PDF
Practical approach to perl day1
PPT
Introduction to Perl
PDF
Introduction to PERL Programming - Complete Notes
PDF
perltut
PDF
perltut
ODP
Introduction to Perl - Day 1
PPT
LPW: Beginners Perl
PPTX
Unit 1-introduction to perl
PPTX
Perl slid
PERL.ppt
Beginning Perl
Introduction to perl scripting______.ppt
Introduction to Perl
Perl Programming_Guide_Document_Refr.ppt
Learn perl in amc square learning
PERL - complete_Training_Modules_Ref.ppt
PERL - complete_guide_references (1).ppt
Perl Basics with Examples
newperl5
newperl5
Practical approach to perl day1
Introduction to Perl
Introduction to PERL Programming - Complete Notes
perltut
perltut
Introduction to Perl - Day 1
LPW: Beginners Perl
Unit 1-introduction to perl
Perl slid
Ad

More from primeteacher32 (20)

PPT
Software Development Life Cycle
PPTX
Variable Scope
PPTX
Returning Data
PPTX
Intro to Functions
PPTX
Introduction to GUIs with guizero
PPTX
Function Parameters
PPTX
Nested Loops
PPT
Conditional Loops
PPTX
Introduction to Repetition Structures
PPTX
Input Validation
PPTX
Windows File Systems
PPTX
Nesting Conditionals
PPTX
Conditionals
PPT
Intro to Python with GPIO
PPTX
Variables and Statements
PPTX
Variables and User Input
PPT
Intro to Python
PPTX
Raspberry Pi
PPT
Hardware vs. Software Presentations
PPTX
Block chain security
Software Development Life Cycle
Variable Scope
Returning Data
Intro to Functions
Introduction to GUIs with guizero
Function Parameters
Nested Loops
Conditional Loops
Introduction to Repetition Structures
Input Validation
Windows File Systems
Nesting Conditionals
Conditionals
Intro to Python with GPIO
Variables and Statements
Variables and User Input
Intro to Python
Raspberry Pi
Hardware vs. Software Presentations
Block chain security

Recently uploaded (20)

PDF
Entrepreneurship PowerPoint for students
PPTX
E-Commerce____Intermediate_Presentation.pptx
PPTX
Nervous_System_Drugs_PPT.pptxXXXXXXXXXXXXXXXXX
PDF
Prostaglandin E2.pdf orthoodontics op kharbanda
PPTX
Principles of Inheritance and variation class 12.pptx
PPTX
cse couse aefrfrqewrbqwrgbqgvq2w3vqbvq23rbgw3rnw345
PPTX
_+✅+JANUARY+2025+MONTHLY+CA.pptx current affairs
PPTX
Definition and Relation of Food Science( Lecture1).pptx
PDF
313302 DBMS UNIT 1 PPT for diploma Computer Eng Unit 2
PPTX
Job-opportunities lecture about it skills
PDF
Blue-Modern-Elegant-Presentation (1).pdf
PPTX
OnePlus 13R – ⚡ All-Rounder King Performance: Snapdragon 8 Gen 3 – same as iQ...
PDF
Why Today’s Brands Need ORM & SEO Specialists More Than Ever.pdf
PDF
L-0018048598visual cloud book for PCa-pdf.pdf
PPTX
Autonomic_Nervous_SystemM_Drugs_PPT.pptx
PPTX
microtomy kkk. presenting to cryst in gl
PPTX
internship presentation of bsnl in colllege
DOCX
How to Become a Criminal Profiler or Behavioural Analyst.docx
PDF
Daisia Frank: Strategy-Driven Real Estate with Heart.pdf
PPTX
The Stock at arrangement the stock and product.pptx
Entrepreneurship PowerPoint for students
E-Commerce____Intermediate_Presentation.pptx
Nervous_System_Drugs_PPT.pptxXXXXXXXXXXXXXXXXX
Prostaglandin E2.pdf orthoodontics op kharbanda
Principles of Inheritance and variation class 12.pptx
cse couse aefrfrqewrbqwrgbqgvq2w3vqbvq23rbgw3rnw345
_+✅+JANUARY+2025+MONTHLY+CA.pptx current affairs
Definition and Relation of Food Science( Lecture1).pptx
313302 DBMS UNIT 1 PPT for diploma Computer Eng Unit 2
Job-opportunities lecture about it skills
Blue-Modern-Elegant-Presentation (1).pdf
OnePlus 13R – ⚡ All-Rounder King Performance: Snapdragon 8 Gen 3 – same as iQ...
Why Today’s Brands Need ORM & SEO Specialists More Than Ever.pdf
L-0018048598visual cloud book for PCa-pdf.pdf
Autonomic_Nervous_SystemM_Drugs_PPT.pptx
microtomy kkk. presenting to cryst in gl
internship presentation of bsnl in colllege
How to Become a Criminal Profiler or Behavioural Analyst.docx
Daisia Frank: Strategy-Driven Real Estate with Heart.pdf
The Stock at arrangement the stock and product.pptx

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

  • #9: 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.