SlideShare a Scribd company logo
1 of 25
Introduction to Perl progammingPart I 16/12/2010 Ernesto Lowy CRG Bioinformatics core
What is Perl? Perl is a programming language extensively used in bioinformatics Created by Larry Wall in 1987 Provides powerful text processing facilities, facilitating easy manipulation of text files Perl is an interpreted language (no compiling is needed) Perl is quite portable  Programs can be written in many different ways (advantage?) Perl slogan is "There's more than one way to do it” Rapid prototyping (solve a problem with fewer lines of code than Java or C)
Installing Perl Perl comes by default on Linux and MacOSX On windows you have to install it: http://strawberryperl.com/ (100% open source) http://www.activestate.com/ (commercial distribution-but free!) Latest version is Perl 5.12.0 	To check if Perl is working and version 	$perl –v
Perl resources	 Web sites www.perl.com http://perldoc.perl.org/ https://www.socialtext.net/perl5/index.cgi http://www.perlmonks.org/ ,[object Object]
 Learning Perl (good for begginers)
 Beginning Perl for Bioinformatics
 Programming Perl (Camel book)
 Perl cookbook,[object Object]
1000 #integer 1.25 #floating-point 1.2e30 #1.2 times 10 to the 30th power -1 -1.2 Only important thing to remember is that you never insert commas or spaces into numbers in Perl. So in a Perl program you never will find: 10 000 10,000 Perl basic data typesNumbers
A string is a collection of characters in either single or double quotes: “This is the CRG.” ‘CRG is in Barcelona!’ Difference between single and double quotes is: print “Hello!My name is Ernesto”; #Interprete contents Will display: >Hello! >My name is Ernesto print ‘Hello!My name is Ernesto’; #contents should be taken literally Will display: >Hello!My name is Ernesto Perl basic data typesStrings
Scalar variables Variable is a name for a container that holds one or more values. Scalar variable (contains a single number or string): $a=1;  $codon=“ATG”; $a_single_peptide=“GMLLKKKI”; (valid Perl identifiers are letter,words,underscore,digits) Important! Scalar variables cannot start with a digit Important! Uppercase and Lowercase letters are distinct ($Maria and $maria) Example (Assignment operator): $codon=“ATG”; print “$codon codes for Methionine”; Will display: ATG codes for Methionine
Numerical operators Perl provides the typical operators. For example: 5+3 #5 plus 3, or 5 3.1-1.2 #3.1 minus 1.2, or 1.9 4*4 # 4 times 4 = 16 6/2 # 6 divided by 2, or 3 Using variables $a=1; $b=2; $c=$a+$b; print “$c”; Will print: 3
Special numerical operators	 $a++; #same than 	$a=$a+1; $b--; #same than 	$b=$b-1; $c +=10; #same than 	$c=$c+10;
String manipulation	 Concatenate strings with the dot operator 	“ATG”.”TCA” # same as “ATGTCA” String repetition operator (x) 	“ATC” x 3   # same as “ATCATCATC” Length() get the length of a string 	$dna=“acgtggggtttttt”; 	print “This sequence has “.length($dna).” nucleotides”; Will print: 	This sequence has 10 nucleotides convert to upper case 	$aa=uc($aa); convert to lower case 	$aa=lc($aa);
Conditional statements(if/else) Determine a particular course of action in the program. Conditional statements make use of the comparison operators to compare numbers or strings. These operators always return true/false as a result of the comparison
Comparison operators(Numbers) Examples: 35 == 35 # true 35 != 35 # false 35 != 32 # ???? 35 == 32+3 # ????
Comparison operators(Strings) Examples: ‘hello’ eq ‘hello’ # true ‘hello’ ne ‘bye’ # true ‘35’ eq ‘35.0’ # ????
If/else statement Allows to control the execution of the program Example: $a=4; $b=10; If ($a>$b) { 	print “$a is greater than $b”; } else { 	print “$b is greater then $a”; }
elsif clause To check a number of conditional expressions, one after another to see which one is true ,[object Object],$outcome=6; #enter here the result from rolling a dice if ($outcome==6)  { 	print “Congrats! You win!”; } elsif ($outcome==4) { 	print “Congrats! You win!”; } elsif ($outcome==2) { 	print “Congrars! You win!”; } else { 	print “Sorry, try again!”; }
Logical operators	 Used to combine conditional expressions || (OR)
Logical operators Example: $day=“Saturday”; if ($day eq “Saturday” || $day eq “Sunday”) { 	print “Hooray! It’s weekend!”; } Will print: >Hooray! It’s weekend!
Logical operators && (AND) Example: $hour=12; if ($hour >=9 && $hour <=18)  { 	“You are supposed to be at work!”; } Will print: >You are supposed to be at work!
Boolean values	 Perl does not have the Boolean data type. So how Perl knows if a given variable is true or false? If the value is a number then 0 means false; all other numbers mean true Example: $a=15; $is_bigger=$a>10; # $is_bigger will be 1 If ($is_bigger) {….}; # this block will be executed
Boolean values	 If a certain value is a string. Then the empty string (‘’) means false; all other strings mean true $day=“”; #evaluates to false, so this block will not be executed if($day) {  	print $day contains a string }
Boolean values Get the opposite of a boolean value (! Operator) Example (A program that expects a filename from the user): print “Enter file name, please”; $file=<>; chomp($file); #remove  from input If (!$file) { #if $file is false (empty string) 	print “I need an input file to proceed”; } #try to process the file

More Related Content

What's hot

Shell Scripting Tutorial | Edureka
Shell Scripting Tutorial | EdurekaShell Scripting Tutorial | Edureka
Shell Scripting Tutorial | EdurekaEdureka!
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisIan Macali
 
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboardsDenis Ristic
 
php 2 Function creating, calling, PHP built-in function
php 2 Function creating, calling,PHP built-in functionphp 2 Function creating, calling,PHP built-in function
php 2 Function creating, calling, PHP built-in functiontumetr1
 
PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2Kumar
 
Anonymous Functions in PHP 5.3 - Matthew Weier O’Phinney
Anonymous Functions in PHP 5.3 - Matthew Weier O’PhinneyAnonymous Functions in PHP 5.3 - Matthew Weier O’Phinney
Anonymous Functions in PHP 5.3 - Matthew Weier O’PhinneyHipot Studio
 
Php Chapter 2 3 Training
Php Chapter 2 3 TrainingPhp Chapter 2 3 Training
Php Chapter 2 3 TrainingChris Chubb
 
PHP7. Game Changer.
PHP7. Game Changer. PHP7. Game Changer.
PHP7. Game Changer. Haim Michael
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requireTheCreativedev Blog
 
Web technology html5 php_mysql
Web technology html5 php_mysqlWeb technology html5 php_mysql
Web technology html5 php_mysqldurai arasan
 

What's hot (20)

Operators in PHP
Operators in PHPOperators in PHP
Operators in PHP
 
Shell Scripting Tutorial | Edureka
Shell Scripting Tutorial | EdurekaShell Scripting Tutorial | Edureka
Shell Scripting Tutorial | Edureka
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards
 
Introduction to php php++
Introduction to php php++Introduction to php php++
Introduction to php php++
 
php 2 Function creating, calling, PHP built-in function
php 2 Function creating, calling,PHP built-in functionphp 2 Function creating, calling,PHP built-in function
php 2 Function creating, calling, PHP built-in function
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2
 
Anonymous Functions in PHP 5.3 - Matthew Weier O’Phinney
Anonymous Functions in PHP 5.3 - Matthew Weier O’PhinneyAnonymous Functions in PHP 5.3 - Matthew Weier O’Phinney
Anonymous Functions in PHP 5.3 - Matthew Weier O’Phinney
 
Php Chapter 2 3 Training
Php Chapter 2 3 TrainingPhp Chapter 2 3 Training
Php Chapter 2 3 Training
 
Download It
Download ItDownload It
Download It
 
PHP Basic
PHP BasicPHP Basic
PHP Basic
 
Functions in php
Functions in phpFunctions in php
Functions in php
 
PHP7. Game Changer.
PHP7. Game Changer. PHP7. Game Changer.
PHP7. Game Changer.
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and require
 
Web technology html5 php_mysql
Web technology html5 php_mysqlWeb technology html5 php_mysql
Web technology html5 php_mysql
 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
 
Functions in PHP
Functions in PHPFunctions in PHP
Functions in PHP
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Introduction in php
Introduction in phpIntroduction in php
Introduction in php
 

Viewers also liked

PERL- Bioperl modules
PERL- Bioperl modulesPERL- Bioperl modules
PERL- Bioperl modulesNixon Mendez
 
BioPerl: The evolution of a Bioinformatics Toolkit
BioPerl: The evolution of a Bioinformatics ToolkitBioPerl: The evolution of a Bioinformatics Toolkit
BioPerl: The evolution of a Bioinformatics ToolkitJason Stajich
 
Bioinformatics and BioPerl
Bioinformatics and BioPerlBioinformatics and BioPerl
Bioinformatics and BioPerlJason Stajich
 
Lecture1 1 Perl for bioinformatics Davide Pisani & James Cotton
Lecture1 1 Perl for bioinformatics Davide Pisani & James CottonLecture1 1 Perl for bioinformatics Davide Pisani & James Cotton
Lecture1 1 Perl for bioinformatics Davide Pisani & James Cottonnathanlawless
 
The Alaska Collection - 2009
The Alaska Collection - 2009The Alaska Collection - 2009
The Alaska Collection - 2009Roger Gillespie
 
Shanthi celebrity advertising indian visual media.
Shanthi celebrity advertising indian visual media.Shanthi celebrity advertising indian visual media.
Shanthi celebrity advertising indian visual media.Shanthi Parasuraman
 
Escultures, Abans i ara, Aquí i allà
Escultures, Abans i ara, Aquí i allàEscultures, Abans i ara, Aquí i allà
Escultures, Abans i ara, Aquí i allàsusaut
 
The best that England has to offer - Scot Carson
The best that England has to offer - Scot CarsonThe best that England has to offer - Scot Carson
The best that England has to offer - Scot CarsonBruce Henderson
 
Lesson 6 understanding you enemy 00
Lesson 6 understanding you enemy 00Lesson 6 understanding you enemy 00
Lesson 6 understanding you enemy 00Elmer Dela Pena
 
Austraalia meestele
Austraalia meesteleAustraalia meestele
Austraalia meesteleTuuli Kotov
 
New Platforms, New Technologies, Old Headaches
New Platforms, New Technologies, Old HeadachesNew Platforms, New Technologies, Old Headaches
New Platforms, New Technologies, Old HeadachesJason Dea
 

Viewers also liked (20)

PERL- Bioperl modules
PERL- Bioperl modulesPERL- Bioperl modules
PERL- Bioperl modules
 
BioPerl: The evolution of a Bioinformatics Toolkit
BioPerl: The evolution of a Bioinformatics ToolkitBioPerl: The evolution of a Bioinformatics Toolkit
BioPerl: The evolution of a Bioinformatics Toolkit
 
Bioinformatics and BioPerl
Bioinformatics and BioPerlBioinformatics and BioPerl
Bioinformatics and BioPerl
 
Lecture1 1 Perl for bioinformatics Davide Pisani & James Cotton
Lecture1 1 Perl for bioinformatics Davide Pisani & James CottonLecture1 1 Perl for bioinformatics Davide Pisani & James Cotton
Lecture1 1 Perl for bioinformatics Davide Pisani & James Cotton
 
Jalase1
Jalase1Jalase1
Jalase1
 
10.1.1.150.595
10.1.1.150.59510.1.1.150.595
10.1.1.150.595
 
Final5for ppp
Final5for pppFinal5for ppp
Final5for ppp
 
The Alaska Collection - 2009
The Alaska Collection - 2009The Alaska Collection - 2009
The Alaska Collection - 2009
 
Technology table
Technology tableTechnology table
Technology table
 
Shanthi celebrity advertising indian visual media.
Shanthi celebrity advertising indian visual media.Shanthi celebrity advertising indian visual media.
Shanthi celebrity advertising indian visual media.
 
Escultures, Abans i ara, Aquí i allà
Escultures, Abans i ara, Aquí i allàEscultures, Abans i ara, Aquí i allà
Escultures, Abans i ara, Aquí i allà
 
Designing call
Designing callDesigning call
Designing call
 
Daktari Newsletter July-August 2012
Daktari Newsletter July-August 2012Daktari Newsletter July-August 2012
Daktari Newsletter July-August 2012
 
The best that England has to offer - Scot Carson
The best that England has to offer - Scot CarsonThe best that England has to offer - Scot Carson
The best that England has to offer - Scot Carson
 
Lesson 6 understanding you enemy 00
Lesson 6 understanding you enemy 00Lesson 6 understanding you enemy 00
Lesson 6 understanding you enemy 00
 
Earth gb
Earth gbEarth gb
Earth gb
 
Austraalia meestele
Austraalia meesteleAustraalia meestele
Austraalia meestele
 
New Platforms, New Technologies, Old Headaches
New Platforms, New Technologies, Old HeadachesNew Platforms, New Technologies, Old Headaches
New Platforms, New Technologies, Old Headaches
 
fashion crazii
fashion craziifashion crazii
fashion crazii
 
Daktari Newsletter August 2010
Daktari Newsletter August 2010Daktari Newsletter August 2010
Daktari Newsletter August 2010
 

Similar to Perl courseparti

Lecture 22
Lecture 22Lecture 22
Lecture 22rhshriva
 
Tutorial perl programming basic eng ver
Tutorial perl programming basic eng verTutorial perl programming basic eng ver
Tutorial perl programming basic eng verQrembiezs Intruder
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to PerlDave Cross
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1Dave Cross
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning PerlDave Cross
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionProf. Wim Van Criekinge
 
You Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager NeedsYou Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager NeedsRoy Zimmer
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationMohammed Farrag
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Andrea Telatin
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottO'Reilly Media
 
Introduction to Modern Perl
Introduction to Modern PerlIntroduction to Modern Perl
Introduction to Modern PerlDave Cross
 

Similar to Perl courseparti (20)

Lecture19-20
Lecture19-20Lecture19-20
Lecture19-20
 
Lecture19-20
Lecture19-20Lecture19-20
Lecture19-20
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Tutorial perl programming basic eng ver
Tutorial perl programming basic eng verTutorial perl programming basic eng ver
Tutorial perl programming basic eng ver
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Perl bhargav
Perl bhargavPerl bhargav
Perl bhargav
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning Perl
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introduction
 
You Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager NeedsYou Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager Needs
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administration
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 
Shell programming
Shell programmingShell programming
Shell programming
 
Introduction to Modern Perl
Introduction to Modern PerlIntroduction to Modern Perl
Introduction to Modern Perl
 
Perl slid
Perl slidPerl slid
Perl slid
 
First steps in C-Shell
First steps in C-ShellFirst steps in C-Shell
First steps in C-Shell
 
Linux Lab Manual.doc
Linux Lab Manual.docLinux Lab Manual.doc
Linux Lab Manual.doc
 
Simple perl scripts
Simple perl scriptsSimple perl scripts
Simple perl scripts
 

Recently uploaded

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Perl courseparti

  • 1. Introduction to Perl progammingPart I 16/12/2010 Ernesto Lowy CRG Bioinformatics core
  • 2. What is Perl? Perl is a programming language extensively used in bioinformatics Created by Larry Wall in 1987 Provides powerful text processing facilities, facilitating easy manipulation of text files Perl is an interpreted language (no compiling is needed) Perl is quite portable Programs can be written in many different ways (advantage?) Perl slogan is "There's more than one way to do it” Rapid prototyping (solve a problem with fewer lines of code than Java or C)
  • 3. Installing Perl Perl comes by default on Linux and MacOSX On windows you have to install it: http://strawberryperl.com/ (100% open source) http://www.activestate.com/ (commercial distribution-but free!) Latest version is Perl 5.12.0 To check if Perl is working and version $perl –v
  • 4.
  • 5. Learning Perl (good for begginers)
  • 6. Beginning Perl for Bioinformatics
  • 7. Programming Perl (Camel book)
  • 8.
  • 9. 1000 #integer 1.25 #floating-point 1.2e30 #1.2 times 10 to the 30th power -1 -1.2 Only important thing to remember is that you never insert commas or spaces into numbers in Perl. So in a Perl program you never will find: 10 000 10,000 Perl basic data typesNumbers
  • 10. A string is a collection of characters in either single or double quotes: “This is the CRG.” ‘CRG is in Barcelona!’ Difference between single and double quotes is: print “Hello!My name is Ernesto”; #Interprete contents Will display: >Hello! >My name is Ernesto print ‘Hello!My name is Ernesto’; #contents should be taken literally Will display: >Hello!My name is Ernesto Perl basic data typesStrings
  • 11. Scalar variables Variable is a name for a container that holds one or more values. Scalar variable (contains a single number or string): $a=1; $codon=“ATG”; $a_single_peptide=“GMLLKKKI”; (valid Perl identifiers are letter,words,underscore,digits) Important! Scalar variables cannot start with a digit Important! Uppercase and Lowercase letters are distinct ($Maria and $maria) Example (Assignment operator): $codon=“ATG”; print “$codon codes for Methionine”; Will display: ATG codes for Methionine
  • 12. Numerical operators Perl provides the typical operators. For example: 5+3 #5 plus 3, or 5 3.1-1.2 #3.1 minus 1.2, or 1.9 4*4 # 4 times 4 = 16 6/2 # 6 divided by 2, or 3 Using variables $a=1; $b=2; $c=$a+$b; print “$c”; Will print: 3
  • 13. Special numerical operators $a++; #same than $a=$a+1; $b--; #same than $b=$b-1; $c +=10; #same than $c=$c+10;
  • 14. String manipulation Concatenate strings with the dot operator “ATG”.”TCA” # same as “ATGTCA” String repetition operator (x) “ATC” x 3 # same as “ATCATCATC” Length() get the length of a string $dna=“acgtggggtttttt”; print “This sequence has “.length($dna).” nucleotides”; Will print: This sequence has 10 nucleotides convert to upper case $aa=uc($aa); convert to lower case $aa=lc($aa);
  • 15. Conditional statements(if/else) Determine a particular course of action in the program. Conditional statements make use of the comparison operators to compare numbers or strings. These operators always return true/false as a result of the comparison
  • 16. Comparison operators(Numbers) Examples: 35 == 35 # true 35 != 35 # false 35 != 32 # ???? 35 == 32+3 # ????
  • 17. Comparison operators(Strings) Examples: ‘hello’ eq ‘hello’ # true ‘hello’ ne ‘bye’ # true ‘35’ eq ‘35.0’ # ????
  • 18. If/else statement Allows to control the execution of the program Example: $a=4; $b=10; If ($a>$b) { print “$a is greater than $b”; } else { print “$b is greater then $a”; }
  • 19.
  • 20. Logical operators Used to combine conditional expressions || (OR)
  • 21. Logical operators Example: $day=“Saturday”; if ($day eq “Saturday” || $day eq “Sunday”) { print “Hooray! It’s weekend!”; } Will print: >Hooray! It’s weekend!
  • 22. Logical operators && (AND) Example: $hour=12; if ($hour >=9 && $hour <=18) { “You are supposed to be at work!”; } Will print: >You are supposed to be at work!
  • 23. Boolean values Perl does not have the Boolean data type. So how Perl knows if a given variable is true or false? If the value is a number then 0 means false; all other numbers mean true Example: $a=15; $is_bigger=$a>10; # $is_bigger will be 1 If ($is_bigger) {….}; # this block will be executed
  • 24. Boolean values If a certain value is a string. Then the empty string (‘’) means false; all other strings mean true $day=“”; #evaluates to false, so this block will not be executed if($day) { print $day contains a string }
  • 25. Boolean values Get the opposite of a boolean value (! Operator) Example (A program that expects a filename from the user): print “Enter file name, please”; $file=<>; chomp($file); #remove from input If (!$file) { #if $file is false (empty string) print “I need an input file to proceed”; } #try to process the file
  • 26. die() function Raises an exception, which means that throws an error message and stops the execution of the program. So previous example revisited: print “Enter file name, please”; $file=<>; chomp($file); #remove from input if (!$file) { #if $file is false (empty string) die(“I need an input file to proceed”); } #process the file only if $file is defined
  • 27. Ex 2. Using conditional expressions TODO: Write a program to get an exam score from the keyboard and prints out a message to the student. Hint: To read input from keyboard enter in your program print "Enter the score of a student: "; $score = <>;
  • 28. Solution #! /usr/bin/perl print "Enter the score of a student: "; $score = <>; if($score>=90) { print "Excellent Performance!"; } elsif ($score>=70 && $score<90) { print "Good Performance!”; } elsif ($score>=50 && $score<70) { print "Uuff! That was close!”; } else { print "Sorry, try harder!"; }

Editor's Notes

  1. -Larry wall is a linguist-what does the Perl interpreter do? It compiles the program (source code) internally intobytecode and then executes it immediately. Perl is commonly known as an interpreted language, but this is not strictly true. Since the interpreter actually does convert the program into byte code before executing it, it is sometimes called an interpreter/compiler , if anything at all. [ 1 ] Although the compiled form is not stored as a file, release 5.005 of Perl includes a working version of a standalone Perl compiler.[1] So do you call something a Perl &quot;script&quot; or a Perl &quot;program&quot;? Typically, the word &quot;program&quot; is used to describe something that needs to be compiled into assembler or byte code before executing, as in the C language, and the word &quot;script&quot; is used to describe something that runs through an interpreter, as in the Bourne shell. For Perl, you can use either phrase and not worry about offending anyone.What does all this brouhaha mean for you? When you write a Perl program, you can just give it a correct #! line at the top of the script, make it executable with chmod +x , and run it. For 95% of Perl programmers in this world, that&apos;s all you&apos;ll care about.
  2. http://perldoc.perl.org/ (official documentation)https://www.socialtext.net/perl5/index.cgi (Perl wiki)
  3. -#! (hash-bang or shebang) tells the shell where to look for perl-The print built-in function is one of the most frequently used parts of Perl. You use it to display things on the screen or to send information to a file.-Perl program consists of statements, each of which ends with a semicolon.-”.pl” extension is optional but is commonly used-”-w” switches on warnings: is not required but it is advisable
  4. -Perl identifier is what follows the dollar sign-Choosing Good Variable Names. You should generally select variable names that mean something regarding the purpose of the variable. For example, $r is probably not very descriptive but $line_length is.