300 likes | 529 Views
Perl part 1. What is perl?. Why perl ?. Good for bioinformatics and web programming Suit for all the operating systems Suit for all kinds of computer Ease of Programming Rapid Prototyping Portability, Speed, and Program Maintenance. Versions of Perl. Perl Version 5
E N D
Why perl? • Good for bioinformatics and web programming • Suit for all the operating systems • Suit for all kinds of computer • Ease of Programming • Rapid Prototyping • Portability, Speed, and Program Maintenance
Versions of Perl • Perl Version 5 • The current version of Perl is 5.8.8. • Perl Version 6 in progress
Installing Perl on Your Computer • $ perl -v • Downloading Unix,Linux:http://www.perl.com/download.csp • Perl for Win32 --http://www.activestate.com/ActivePerl/
How to Run Perl Programs • Windows : typing this_program in an MS-DOS command window or by typing perlthis_program.pl. Linux: make the program executable using the chmod program : chmod 755 this_program OR perl /usr/local/bin/this_program
Text Editors • Linux :vi and emacs • Windows:Notepad ;word;
Good start for Programming • Take classes of many different kinds • Read a tutorial book like this one • Get the programming manuals and plunge in • Be tutored by a programmer • Identify a program you need • Try any and all of the above until you've managed to write the program • Edit—Run—Revise (and Save)
Scalar Data • A scalar is the simplest kind of data that Perl manipulates. Most scalars are a number (like 255 or 3.25e20) or a string of characters (like hello[ ] or the Gettysburg Address).
Numbers • Floating-Point Literals • Integer Literals • Non-Decimal Integer Literals
Strings • Strings are sequences of characters (like hello). Strings may contain any combination of any characters.The shortest possible string has no characters. The longest string fills all of your available memory.
Single-Quoted String Literals A single-quoted string literal is a sequence of characters enclosed in single quotes. The single quotes are not part of the string itself but are there to let Perl identify the beginning and the ending of the string.
Double-Quoted String Literals • A double-quoted string literal is similar to single-quoted string literal , But now the backslash takes on its full power to specify certain control characters or any character through octal and hex representations.
Automatic Conversion Between Numbers and Strings • Check the operator
Perl's Built-in Warnings • -w option • $ perl -w my_program • #!/usr/bin/perl -w
Scalar Variables • A variable is a name for a container that holds one or more values • A scalar variable holds a single scalar value as you'd expect. Scalar variable names begin with a dollar sign $ • can't start with a digit
Scalar Assignment • The most common operation on a scalar variable is assignment, which is the way to give a value to a variable. The Perl assignment operator is the equals sign = (much like other languages), which takes a variable name on the left side and gives it the value of the expression on the right:
Lists and Arrays • A list is an ordered collection of scalars. An array is a variable that contains a list.