SlideShare a Scribd company logo
Perl Programming
Course
Introduction to PerlIntroduction to Perl
Krasimir Berov
I-can.eu With the kind contribution of Chain Solutions
Contents
1. Brief History
2. Basic concepts. Interpreted (scripting) or compiled?
3. Virtual machine and platform abstraction
4. Why Perl?
5. CPAN and PPM
6. Installing on (Windows/Unix)
7. Basic syntax
8. Builtin operators and functions
9. Hello World
10.Resources
Brief History
● 1986/7 – Perl was invented by Larry Wall at NASA's Jet
Propulsion Labs
● 1987-Dec-18 Perl 1 introduced Perl to the world.
● 1988-Jun-05 Perl 2 introduced Henry Spencer's regular
expression package.
● 1989-Oct-18 Perl 3 introduced the ability to handle binary
data.
● 1991-Mar-21 Perl 4 introduced the first Camel book.
● 1994-Oct-17 Perl 5 introduced everything else,
(OOP, threads...) including the ability to introduce everything
else.
● 2014-05-27 Perl 5.20 has been released by Ricardo Signes.
Basic concepts
● P.E.R.L (Pathologically Eclectick Rubish Lister)
or
P.E.R.L (Practical Extraction and Report
Language)
● Programming Languages
● Interpreted and compiled languages
Basic concepts
● Programming languages
● C/C++
● Java
● Tcl
● Perl
● PHP
● Ruby
● JavaScript
● ….
Basic concepts
● Interpreted or Compiled is Perl?
Basic concepts
● Interpreted?
– An interpreted language needs a program called an
interpreter to process the source code every time you
run the program.
– The interpreter translates the source code down to
machine code, because it's for machines to read.
– Source code is for humans.
● Details:
– perlhack/Elements of the interpreter
– perlguts/Compiled code
● Interpreted languages: Perl, PHP, Python, Ruby...
Basic concepts
● Compiled?
– A compiled language uses a compiler to do all this
processing one time only.
– After that, you can run the produced machine code
many times on many machines without needing the
compiler.
● Compiled languages: C,C++, D, Delphy,..
● Byte-compiled languages: Java, Python, Perl (Parrot-
Perl6,Java-Perl6) :)...
● The byte code should be machine independent too
– Not as portable as Perl source
(see perlcompile, B::Bytecode).
Virtual machine
● Virtual machine == perl the program/interpreter
● The work of the interpreter has two main stages:
– compiling the code into the internal
representation (bytecode)
– executing it.
● Virtual machine for Perl 6 – Parrot is more like
Java and .NET.
● Perl6 is being ported to the Java platform too
(https://github.com/jnthn/nqp-jvm-prep).
Virtual machine
● Short breakdown of perl's work
– Compilation
● Startup
● Parsing
● Compilation and Optimization
– Run
● Running
● Exception handing
Platform abstraction
● Perl's virtual machine permits us not to think about
the specifics of the OS.
● High level of abstraction
● The same source code is run on different
platforms:
use File::Path;use File::Path;
my $dest ='/some/path/in/main/drive'my $dest ='/some/path/in/main/drive'
eval { mkpath($dest) };eval { mkpath($dest) };
if ($@) {if ($@) {
print "Couldn't create $dest:$/$@$/"print "Couldn't create $dest:$/$@$/"
. "... exiting.$/";. "... exiting.$/";
exit;exit;
}}
Why Perl?
● Easy to learn
– Learning a little Perl can get you farther than
expected.
– Easy for humans to write, rather than easy for
computers to understand.
– The syntax of the language is a lot more like a
human language .
open(FILE) or die $!; #same as belowopen(FILE) or die $!; #same as below
die $! unless open(FILE);#same as abovedie $! unless open(FILE);#same as above
die $! if not open(FILE);#same as abovedie $! if not open(FILE);#same as above
Why Perl?
● Portable
– Perl is ported to almost all modern operating systems
such as Windows, Mac OS X, Linux, Unix (created
on) and many others...
● Very high level language
– Does not make you think about obscure things like
memory allocation, CPU, etc.
Why Perl?
● „Talks“ text (in any encoding).
● „Thinks“ about files in terms of lines and sentences (by
default) or as you tell it to.
● Has powerful regular expressions built in.
if( $lines[$_] =~ /^--s*?[(w+)]/ ){if( $lines[$_] =~ /^--s*?[(w+)]/ ){
$key = $1;$key = $1;
}}
WARNING!!!
Do not write sloppy code just because it is easy to do so. In most cases
Your code lives longer than you expected and gets uglier!!!
Why Perl?
● Finally,
– Because you want so
– because your boss wants so :)...
CPAN and PPM
● Comprehensive Perl Archive Network is the
biggest source for reusable, standardized perl-
code.
Use the cpan program to install compile and
upgrade modules if you have a C compiler.
● Perl Package Manager is the ActiveState tool for
precompiled perl modules
It simplifies the task of locating, installing,
upgrading and removing Perl packages on
Windows. Use the ppm program that comes with
ActivePerl.
Installing on (Windows/Unix)
– Linux/Unix
● No need – you already have it.
● Use perlbrew to install your own Perl.
● Use your own ActivePerl.
– Windows
● Download perl for your architecture from
http://strawberryperl.com/
or
http://www.activestate.com/activeperl/downloads
● Click twice on
strawberry-perl-5.XX.X.X-32bit.msi
or
ActivePerl-5.XX.X.XXXX-....msi
1.Next, next, mm.. next, yes, next.... :D
Basic syntax
● A Perl script or program consists of one or more
statements.
● These statements are simply written in the script
in a straightforward fashion.
● There is no need to have a main() function or
anything of that kind.
Basic syntax
● Perl statements end in a semi-colon
#this is a fully functional program#this is a fully functional program
print "Hello, world";print "Hello, world";
Basic syntax
● Comments start with a hash symbol and run to
the end of the line
#this is a fully functional program with comment#this is a fully functional program with comment
print "Hello, world";print "Hello, world";
Basic syntax
● Whitespace is irrelevant
printprint
"Hello, world""Hello, world"
;;
Basic syntax
● ... except inside quoted strings
# this would print with a line-break in the middle# this would print with a line-break in the middle
print "Helloprint "Hello
world";world";
Basic syntax
● Double quotes or single quotes may be used
around literal strings
print "Hello, world";print "Hello, world";
print 'Hello, world';print 'Hello, world';
Basic syntax
● However, only double quotes "interpolate"
variables and special characters such as
newlines (n)
print "Hello, $namen"; # works fineprint "Hello, $namen"; # works fine
print 'Hello, $namen'; # prints $namen literallyprint 'Hello, $namen'; # prints $namen literally
Basic syntax
● Numbers don't need quotes around them
print 42;print 42;
Basic syntax
● You can use parentheses for functions'
arguments or omit them according to your
personal taste.
● Only required occasionally to clarify issues of
precedence.
print("Hello, worldn");print("Hello, worldn");
print "Hello, worldn";print "Hello, worldn";
Builtin operators and functions
● Perl comes with a wide selection of builtin
functions.
● Full list at the start of the perlfunc manpage.
● You can read about any given function by using
perldoc -f functionname at the
commandline.
● Perl operators are documented in full in the
perlop manpage
● Here are a few of the most common ones.
Builtin operators and functions
● Arithmetic
+ addition
- subtraction
* multiplication
/ division
Builtin operators and functions
● Numeric comparison
== equality
!= inequality
< less than
> greater than
<= less than or equal
>= greater than or equal
Builtin operators and functions
● String comparison
eq equality
ne inequality
lt less than
gt greater than
le less than or equal
ge greater than or equal
● Why separate numeric and string comparisons?
– Perl does not have special variable types.
– perl needs to know whether to sort numerically or
alphabetically.
Builtin operators and functions
● Boolean logic
&& and
|| or
! not
● and, or and not aren't just descriptions of the operators
-- they're:
– operators in their own right.
– more readable than the C-style operators
– lower precedence to && and friends.
● See perlop.
Builtin operators and functions
● Miscellaneous
= assignment
. string concatenation
x string multiplication
.. range operator (creates a list of numbers)
Builtin operators and functions
● Many operators can be combined with a = as
follows:
$a += 1; # same as $a = $a + 1$a += 1; # same as $a = $a + 1
$a -= 1; # same as $a = $a - 1$a -= 1; # same as $a = $a - 1
$a .= "n"; # same as $a = $a . "n";$a .= "n"; # same as $a = $a . "n";
Hello World
#!/usr/bin/perl#!/usr/bin/perl
use warnings;use warnings;
use strict;use strict;
use utf8;use utf8;
print 'Hi'.$/;print 'Hi'.$/;
So called shebang line.
Optional on Windows
Perl pragma to control optional warnings
Perl pragma to restrict unsafe constructs
Perl pragma to enable/disable UTF-8 in
source code (You love Unicode, right?).
Prints a string or a list of strings. A literal string(scalar value).
The input record separator, newline by
default. This influences Perl's idea of what a
"line" is.
Resources
● Perl CORE documentation
– perlhist, perlintro, perldata, perlhack, perlguts,
perlvar, perlcompile, etc.
● „Beginning Perl“ by Simon Cosens with Peter
Wainwright (Wrox Press Ltd. 2000)
http://www.perl.org/books/beginning-perl/
● Modern Perl by chromatic
http://www.onyxneon.com/books/modern_perl/
● See also: books.perl.org
Introduction to Perl
Questions?

More Related Content

PDF
Yapc::NA::2009 - Command Line Perl
PDF
IO Streams, Files and Directories
PPT
Perl Basics with Examples
PDF
Introduction to Perl and BioPerl
PDF
Perl Programming - 01 Basic Perl
PPTX
Unit 1-introduction to perl
PPTX
Bioinformatics p1-perl-introduction v2013
Yapc::NA::2009 - Command Line Perl
IO Streams, Files and Directories
Perl Basics with Examples
Introduction to Perl and BioPerl
Perl Programming - 01 Basic Perl
Unit 1-introduction to perl
Bioinformatics p1-perl-introduction v2013

What's hot (20)

PPT
Perl tutorial
ODP
Perl Introduction
PPTX
PPT
Programming in Computational Biology
PPTX
Streams, sockets and filters oh my!
PDF
Perl Programming - 02 Regular Expression
PDF
Spl in the wild
PDF
PHP7 is coming
PDF
SPL to the Rescue - Tek 09
PPTX
ODP
PHP Web Programming
PPT
Introduction to php php++
PPT
Hacking with hhvm
PPT
PHP - Introduction to PHP Functions
PPTX
Php extensions
PDF
Power of Puppet 4
PDF
Writing and using php streams and sockets tek11
Perl tutorial
Perl Introduction
Programming in Computational Biology
Streams, sockets and filters oh my!
Perl Programming - 02 Regular Expression
Spl in the wild
PHP7 is coming
SPL to the Rescue - Tek 09
PHP Web Programming
Introduction to php php++
Hacking with hhvm
PHP - Introduction to PHP Functions
Php extensions
Power of Puppet 4
Writing and using php streams and sockets tek11
Ad

Viewers also liked (14)

PPTX
Moo the universe and everything
PDF
Introduction to OO Perl with Moose
PDF
FINAL-PEBMETAL-BROCHER
PDF
Negocio propio enzactalargo
PDF
Jornadas Monitor Turespaña Mercado Britanico
PPS
El Pintor Musical De Venecia
PDF
Dashboard analytics 4th quarter 2015
PDF
A Pathway2Work Success Story - A Testimonial from an employer for the Work Pr...
PPTX
Las piedras preciosas
PPS
Baila como-si-nadie-te-viera
PPT
Partes internas del cpu victoria
PDF
Análisis e interpretación de estados financieros
PPT
IS740 Chapter 10
PDF
TRATAMIENTO PERCUTÁNEO DE LA HIDATIDOSIS HEPÁTICA
Moo the universe and everything
Introduction to OO Perl with Moose
FINAL-PEBMETAL-BROCHER
Negocio propio enzactalargo
Jornadas Monitor Turespaña Mercado Britanico
El Pintor Musical De Venecia
Dashboard analytics 4th quarter 2015
A Pathway2Work Success Story - A Testimonial from an employer for the Work Pr...
Las piedras preciosas
Baila como-si-nadie-te-viera
Partes internas del cpu victoria
Análisis e interpretación de estados financieros
IS740 Chapter 10
TRATAMIENTO PERCUTÁNEO DE LA HIDATIDOSIS HEPÁTICA
Ad

Similar to Introduction to Perl (20)

PPT
PERL - complete_Training_Modules_Ref.ppt
PPT
PERL - complete_guide_references (1).ppt
PDF
Introduction to PERL Programming - Complete Notes
PPT
Perl Programming_Guide_Document_Refr.ppt
PDF
perltut
PDF
perltut
PPTX
python and perl
PPTX
File handle in PROGRAMMable extensible interpreted .pptx
PPT
Introduction to perl scripting______.ppt
PDF
Perl University: Getting Started with Perl
PDF
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
PPTX
Perl bhargav
PDF
Cs3430 lecture 15
PPT
Introduction to Perl
PPT
Perl Development (Sample Courseware)
PPTX
Perl slid
PPTX
programming language interface i.pptx
PDF
Perl 101
PDF
newperl5
PERL - complete_Training_Modules_Ref.ppt
PERL - complete_guide_references (1).ppt
Introduction to PERL Programming - Complete Notes
Perl Programming_Guide_Document_Refr.ppt
perltut
perltut
python and perl
File handle in PROGRAMMable extensible interpreted .pptx
Introduction to perl scripting______.ppt
Perl University: Getting Started with Perl
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
Perl bhargav
Cs3430 lecture 15
Introduction to Perl
Perl Development (Sample Courseware)
Perl slid
programming language interface i.pptx
Perl 101
newperl5

More from Krasimir Berov (Красимир Беров) (12)

Recently uploaded (20)

PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation theory and applications.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Cloud computing and distributed systems.
PDF
Empathic Computing: Creating Shared Understanding
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Modernizing your data center with Dell and AMD
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
Teaching material agriculture food technology
Dropbox Q2 2025 Financial Results & Investor Presentation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation theory and applications.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Spectral efficient network and resource selection model in 5G networks
The Rise and Fall of 3GPP – Time for a Sabbatical?
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Cloud computing and distributed systems.
Empathic Computing: Creating Shared Understanding
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Machine learning based COVID-19 study performance prediction
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Understanding_Digital_Forensics_Presentation.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Modernizing your data center with Dell and AMD
Building Integrated photovoltaic BIPV_UPV.pdf
Teaching material agriculture food technology

Introduction to Perl

  • 1. Perl Programming Course Introduction to PerlIntroduction to Perl Krasimir Berov I-can.eu With the kind contribution of Chain Solutions
  • 2. Contents 1. Brief History 2. Basic concepts. Interpreted (scripting) or compiled? 3. Virtual machine and platform abstraction 4. Why Perl? 5. CPAN and PPM 6. Installing on (Windows/Unix) 7. Basic syntax 8. Builtin operators and functions 9. Hello World 10.Resources
  • 3. Brief History ● 1986/7 – Perl was invented by Larry Wall at NASA's Jet Propulsion Labs ● 1987-Dec-18 Perl 1 introduced Perl to the world. ● 1988-Jun-05 Perl 2 introduced Henry Spencer's regular expression package. ● 1989-Oct-18 Perl 3 introduced the ability to handle binary data. ● 1991-Mar-21 Perl 4 introduced the first Camel book. ● 1994-Oct-17 Perl 5 introduced everything else, (OOP, threads...) including the ability to introduce everything else. ● 2014-05-27 Perl 5.20 has been released by Ricardo Signes.
  • 4. Basic concepts ● P.E.R.L (Pathologically Eclectick Rubish Lister) or P.E.R.L (Practical Extraction and Report Language) ● Programming Languages ● Interpreted and compiled languages
  • 5. Basic concepts ● Programming languages ● C/C++ ● Java ● Tcl ● Perl ● PHP ● Ruby ● JavaScript ● ….
  • 6. Basic concepts ● Interpreted or Compiled is Perl?
  • 7. Basic concepts ● Interpreted? – An interpreted language needs a program called an interpreter to process the source code every time you run the program. – The interpreter translates the source code down to machine code, because it's for machines to read. – Source code is for humans. ● Details: – perlhack/Elements of the interpreter – perlguts/Compiled code ● Interpreted languages: Perl, PHP, Python, Ruby...
  • 8. Basic concepts ● Compiled? – A compiled language uses a compiler to do all this processing one time only. – After that, you can run the produced machine code many times on many machines without needing the compiler. ● Compiled languages: C,C++, D, Delphy,.. ● Byte-compiled languages: Java, Python, Perl (Parrot- Perl6,Java-Perl6) :)... ● The byte code should be machine independent too – Not as portable as Perl source (see perlcompile, B::Bytecode).
  • 9. Virtual machine ● Virtual machine == perl the program/interpreter ● The work of the interpreter has two main stages: – compiling the code into the internal representation (bytecode) – executing it. ● Virtual machine for Perl 6 – Parrot is more like Java and .NET. ● Perl6 is being ported to the Java platform too (https://github.com/jnthn/nqp-jvm-prep).
  • 10. Virtual machine ● Short breakdown of perl's work – Compilation ● Startup ● Parsing ● Compilation and Optimization – Run ● Running ● Exception handing
  • 11. Platform abstraction ● Perl's virtual machine permits us not to think about the specifics of the OS. ● High level of abstraction ● The same source code is run on different platforms: use File::Path;use File::Path; my $dest ='/some/path/in/main/drive'my $dest ='/some/path/in/main/drive' eval { mkpath($dest) };eval { mkpath($dest) }; if ($@) {if ($@) { print "Couldn't create $dest:$/$@$/"print "Couldn't create $dest:$/$@$/" . "... exiting.$/";. "... exiting.$/"; exit;exit; }}
  • 12. Why Perl? ● Easy to learn – Learning a little Perl can get you farther than expected. – Easy for humans to write, rather than easy for computers to understand. – The syntax of the language is a lot more like a human language . open(FILE) or die $!; #same as belowopen(FILE) or die $!; #same as below die $! unless open(FILE);#same as abovedie $! unless open(FILE);#same as above die $! if not open(FILE);#same as abovedie $! if not open(FILE);#same as above
  • 13. Why Perl? ● Portable – Perl is ported to almost all modern operating systems such as Windows, Mac OS X, Linux, Unix (created on) and many others... ● Very high level language – Does not make you think about obscure things like memory allocation, CPU, etc.
  • 14. Why Perl? ● „Talks“ text (in any encoding). ● „Thinks“ about files in terms of lines and sentences (by default) or as you tell it to. ● Has powerful regular expressions built in. if( $lines[$_] =~ /^--s*?[(w+)]/ ){if( $lines[$_] =~ /^--s*?[(w+)]/ ){ $key = $1;$key = $1; }} WARNING!!! Do not write sloppy code just because it is easy to do so. In most cases Your code lives longer than you expected and gets uglier!!!
  • 15. Why Perl? ● Finally, – Because you want so – because your boss wants so :)...
  • 16. CPAN and PPM ● Comprehensive Perl Archive Network is the biggest source for reusable, standardized perl- code. Use the cpan program to install compile and upgrade modules if you have a C compiler. ● Perl Package Manager is the ActiveState tool for precompiled perl modules It simplifies the task of locating, installing, upgrading and removing Perl packages on Windows. Use the ppm program that comes with ActivePerl.
  • 17. Installing on (Windows/Unix) – Linux/Unix ● No need – you already have it. ● Use perlbrew to install your own Perl. ● Use your own ActivePerl. – Windows ● Download perl for your architecture from http://strawberryperl.com/ or http://www.activestate.com/activeperl/downloads ● Click twice on strawberry-perl-5.XX.X.X-32bit.msi or ActivePerl-5.XX.X.XXXX-....msi 1.Next, next, mm.. next, yes, next.... :D
  • 18. Basic syntax ● A Perl script or program consists of one or more statements. ● These statements are simply written in the script in a straightforward fashion. ● There is no need to have a main() function or anything of that kind.
  • 19. Basic syntax ● Perl statements end in a semi-colon #this is a fully functional program#this is a fully functional program print "Hello, world";print "Hello, world";
  • 20. Basic syntax ● Comments start with a hash symbol and run to the end of the line #this is a fully functional program with comment#this is a fully functional program with comment print "Hello, world";print "Hello, world";
  • 21. Basic syntax ● Whitespace is irrelevant printprint "Hello, world""Hello, world" ;;
  • 22. Basic syntax ● ... except inside quoted strings # this would print with a line-break in the middle# this would print with a line-break in the middle print "Helloprint "Hello world";world";
  • 23. Basic syntax ● Double quotes or single quotes may be used around literal strings print "Hello, world";print "Hello, world"; print 'Hello, world';print 'Hello, world';
  • 24. Basic syntax ● However, only double quotes "interpolate" variables and special characters such as newlines (n) print "Hello, $namen"; # works fineprint "Hello, $namen"; # works fine print 'Hello, $namen'; # prints $namen literallyprint 'Hello, $namen'; # prints $namen literally
  • 25. Basic syntax ● Numbers don't need quotes around them print 42;print 42;
  • 26. Basic syntax ● You can use parentheses for functions' arguments or omit them according to your personal taste. ● Only required occasionally to clarify issues of precedence. print("Hello, worldn");print("Hello, worldn"); print "Hello, worldn";print "Hello, worldn";
  • 27. Builtin operators and functions ● Perl comes with a wide selection of builtin functions. ● Full list at the start of the perlfunc manpage. ● You can read about any given function by using perldoc -f functionname at the commandline. ● Perl operators are documented in full in the perlop manpage ● Here are a few of the most common ones.
  • 28. Builtin operators and functions ● Arithmetic + addition - subtraction * multiplication / division
  • 29. Builtin operators and functions ● Numeric comparison == equality != inequality < less than > greater than <= less than or equal >= greater than or equal
  • 30. Builtin operators and functions ● String comparison eq equality ne inequality lt less than gt greater than le less than or equal ge greater than or equal ● Why separate numeric and string comparisons? – Perl does not have special variable types. – perl needs to know whether to sort numerically or alphabetically.
  • 31. Builtin operators and functions ● Boolean logic && and || or ! not ● and, or and not aren't just descriptions of the operators -- they're: – operators in their own right. – more readable than the C-style operators – lower precedence to && and friends. ● See perlop.
  • 32. Builtin operators and functions ● Miscellaneous = assignment . string concatenation x string multiplication .. range operator (creates a list of numbers)
  • 33. Builtin operators and functions ● Many operators can be combined with a = as follows: $a += 1; # same as $a = $a + 1$a += 1; # same as $a = $a + 1 $a -= 1; # same as $a = $a - 1$a -= 1; # same as $a = $a - 1 $a .= "n"; # same as $a = $a . "n";$a .= "n"; # same as $a = $a . "n";
  • 34. Hello World #!/usr/bin/perl#!/usr/bin/perl use warnings;use warnings; use strict;use strict; use utf8;use utf8; print 'Hi'.$/;print 'Hi'.$/; So called shebang line. Optional on Windows Perl pragma to control optional warnings Perl pragma to restrict unsafe constructs Perl pragma to enable/disable UTF-8 in source code (You love Unicode, right?). Prints a string or a list of strings. A literal string(scalar value). The input record separator, newline by default. This influences Perl's idea of what a "line" is.
  • 35. Resources ● Perl CORE documentation – perlhist, perlintro, perldata, perlhack, perlguts, perlvar, perlcompile, etc. ● „Beginning Perl“ by Simon Cosens with Peter Wainwright (Wrox Press Ltd. 2000) http://www.perl.org/books/beginning-perl/ ● Modern Perl by chromatic http://www.onyxneon.com/books/modern_perl/ ● See also: books.perl.org