Lecture4 - Lecture 4 Perl Tutorial Common Programming...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 4: Perl Tutorial • Tutorial on Programming in Perl Common Programming Language Constructs • Variables and Assignment • Variable types: Arrays, Hashes, and Scalars • Arithmetic Operators • Logical Operators • Conditional Statements • Loops • Input/Output • Array and Hash Functions • Regular Expressions • Database Functions Why Perl? § Perl = P ractical E xtraction and R eport L anguage § Advantages: • Scripting Language: fast to write • Relatively easy first language to learn • Built-in tools: Regular Expressions, etc. • Runs on most operating systems: Linux, Mac, Windows • Perl community: CPAN, modules. • Bioinformatics tools: Bioperl • Web programming: CGI.pm or mod_perl § To learn more about Perl: Learning Perl by Randal L. Schwartz and Tom Christiansen Beginning Perl for Bioinformatics by James Tisdall Programming Perl by Larry Wall and Tom Christiansen www.perl.com/perl and www.perl.com/cpan Perl: Basic Syntax Rules § Statements are terminated by a semi-colon • print (“Hello!\n”) ; § Text blocks are demarcated by curly brackets • if ($a == $b) { print (“a = b!\n”); } § Comments are indicated by a sharp sign (rest of line is a comment) • $a = 10; # Set $a equal to ten. § Separate variable names and tokens with spaces, otherwise space has no meaning. • $a + $b; is the same as $a + $b; § Common conventions: \n = newline, \t = tab, “ ” = string § Order matters: statements are evaluated in descending order
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Perl: Assignment Assignment: § Equal sign represents variable assignment • $text = “B”; § Binary assignment operators: • $numA = $numA + 5; => $numA += 5; • $B = $B - 6; => $B -= 6; Perl: Variable types § Dollar-sign ($) variable represents a scalar; a scalar can be a number or a string $ DNA_length = 20; $ DNA_sequence = “ATTAGCCGAATTGGCCAAGG”; § At-sign (@) variable represents an array Dollar-sign ($) sign represents individual array element @ DNA = (“A”,”T”,”T”,”A”,”G”,”C”,”C”,”G”,”A”,”A”,”T,”T”,”G”,”G”,”C”,”C”,”A”,”A”,”G”,”G”);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/20/2012 for the course MBIOS 478 taught by Professor Staff during the Fall '11 term at Washington State University .

Page1 / 5

Lecture4 - Lecture 4 Perl Tutorial Common Programming...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online