Presentation is loading. Please wait.

Presentation is loading. Please wait.

Perl Programming Dr Claire Lambert

Similar presentations


Presentation on theme: "Perl Programming Dr Claire Lambert"— Presentation transcript:

1 Perl Programming Dr Claire Lambert
MSc Bioinformatics Perl Programming Dr Claire Lambert

2 Data Types Scalars Arrays of scalars
Associative arrays of scalars (hashes)

3 Literals Never changes - fixed number string array associative array

4 Variables Can change within the program number string array
associative array

5 Operators Addition Subtraction Multiplication Division + or += - or -=

6 Logical operators AND OR NOT true AND true then true
false OR false then false NOT changes state true becomes false false becomes true

7 Relational operators Equality Comparison Numeric Strings == , !=
eq , ne Comparison <, <=, >, >=, <=> lt, le, gt, ge, cmp

8 You should now be able to
Setup appropriate data structures define different types and give examples illustrate operators that can be used write perl programs

9 Programming style Good programming principles correctness efficiency
transparency, readability modifiablity robustness documentation

10 Programming style Importance of criteria
depends on problem circumstances in which program is written environment in which program is to be used correctness has highest priority other criteria usually equal weight

11 Programming style Common mistake start writing immediately
use stepwise refinement top down design top level - algorithm bottom level - primitive statements

12 Programming style Why conform to conventions? reduce risk of errors
produce programs readable easy to understand easy to debug easy to modify or extend

13 Programming style Good style rules short statements
procedures, functions, modules good naming of data objects layout for readability

14 Programming style Comments under-commenting over-commenting
main purpose enable user to use program to understand program to modify program

15 Programming style Comments what program does? how it is run
execution time and memory requirements limitations special system requirements functions and arguments implementation information

16 Programming style Efiiciency execution time space requirements
improvements deeper understanding of problem better programming perl interpreter execution efficiency compilers are better at this

17 You should now be able to
Describe good programming principles (criteria) the importance of the criteria identify common mistakes made explain why conform to style identify good rules of style why use comments, examples identify areas of efficiency

18 Debugging Debugging Debugger getting rid of errors
syntax and logical Debugger tool to allow control when executing the program breakpoints print variable values

19 Debugging Syntax errors Common syntax errors compile-time errors
error message generated Common syntax errors missing semi-colon string terminator “ errors not always on line specified errors may not be related to message generated

20 Debugging Logical errors Perl -w filename.pl Debugger bugs
extra warnings unused variables (typo) variables used before they are set Debugger trace, breakpoints and actions print variable values

21 Debugging Strict forces declaration of variables
does not allow mis-referencing

22 Debugging Debugger DB<1> a [line] ACTION b [line] L d [line]
X variable s and n c [line]

23 You should now be able to
Define what debugging is identify types of errors and common errors explain command line option -w use strict to force variable declaration use a debugger for a perl program


Download ppt "Perl Programming Dr Claire Lambert"

Similar presentations


Ads by Google