Common Beginner Errors in Perl


Before wasting the teachers time, go through the check list


Syntax errors (program will not compile)

1) You have forgotton the semicolon (;) in the end of a statement.

2) You wrote a reserved word with a capital letter (If instead of if, etc).

3) You began a text string with a quote " but did not end with ".

4) You do not have matching parenthesis (), braces {} or brackets [].

Trivial semantic errors (program will not run right)

5) You have forgotten to use chomp on input from keyboard or file.

6) You used eq, ne, lt, le, gt, ge, instead of ==, !=, <, <=, >, >= in a comparison or vice versa.

7) You used = instead of == in a comparison.

8) You used a variable before assigning a value to it.

9) You made a never-ending loop, because you did not increment the loop counter.


Good advice

Use syntax highlighting to catch many errors.

Put -w in the line: #!/usr/bin/perl -w

Write comments in your perl code.

Use well worded and differentiated print statements, so you know where you are in the program, and what output you have.


This page was last updated         by Peter Wad Sackett, pws@cbs.dtu.dk


GOTO Home Page Email Webmaster