Download presentation
Presentation is loading. Please wait.
1
INTRODUCTION to PERL PART 1
2
Background Practical Extraction and Report Language → Perl
Developed in 1987 by Larry Wall
3
SCALAR — The Basic Unit of Perl
Scalar = number or string $scalar = “that’s me!”; # ‘$’ is used to declare scalars Default value: “undef” 0 as a number NULL as a string
4
SCALAR — The Basic Unit of Perl
$alice = 5; $bob = “5”; Dynamically typed $alice == $bob # true Can be accessed inside a string literal print “What comes after 4? $alice”; # What comes after 4? 5
5
Operators Operators Assignment = Arithmetic + - * / String . x
Comparison == != < > <= >= eq ne lt gt le ge
6
ASSIGNMENT OPERATOR $var = “value”; # value
7
ARITHMETIC OPERATORS $var = 10 + 2; # 2 $var = 10 – 2; # 8
8
STRING OPERATORS $var = “Hello ” . “world!”; # Hello world!
$var = “Yeah! ” x 3; # Yeah! Yeah! Yeah!
9
NUMBER COMPARISON OPERATORS
$alice == $bob; $alice != $bob; $alice < $bob; $alice > $bob; $alice <= $bob; $alice >= $bob;
10
STRING COMPARISON OPERATORS
$alice eq $bob; $alice ne $bob; $alice lt $bob; $alice gt $bob; $alice le $bob; $alice ge $bob;
11
IF — CONTROL STRUCTURES
if (condition) { # code goes here! } else {
12
While — Control Structures
while (condition) { # code goes here! }
13
STANDARD INPUT <STDIN> $input = <STDIN>;
14
LISTS & Arrays List = collection of scalars
(“that’s”, “me!”); # lists are enclosed in parentheses Array = variable that stores a list @array = (“that’s”, “me!”); # arrays are declared with Accessed with ‘$’ and ‘[]’ $item = $array[0]; # that’s
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.