Friday, January 14, 2011

Common errors in perl


Check for these common errors before you try to debug a program:
  • no semi-colon at end of line.
  • matching pairs of delimiters: ( ), { }, [ ].
  • Using = when you mean ==.
  • Using == when you mean eq.
  • Using == when you mean =~.
  • Disagreement of field, array or hash names (remember $data,$data[1],$data{1} and $Data are four different entities.
  • Disagreement of subroutine names between execution and definition.
  • Incorrect use of if, elsif, else.
  • Not checking your program (and correcting the errors) using the -w switch.

No comments: