Search your unanswered perl queries
Google

Thursday, November 22, 2007

Some Perl Tips

  1. No doubt the first tip is to use strict in whatever code you write. It helps in avoiding the typo and many other errors which otherwise are real difficult to bebug.
  2. When using if it is not necessary to emboss the condition in ()’s when if is used as the last part of the statement.
  3. @ARGV is the array which holds all the parameters passed to a perl program through a command line.
  4. For conditions in perl “”, 0 , “0”, undefined is false, everything else is true.
  5. It is confusing for some people to remember how unless works. One can remember it in a simple way by saying if not this then this happens. i.e unless (people){do this}; can be interpreted as if not people do this.
  6. When you want to comment a large amount of code you can always use a condition which will always be false. eg. if (1 > 2) { ...... }

If anyone of you have any other perl tips which you follow as a practice, please leave it in the comments section. I would like to add it to the list with your name as contributor and let people efficiently do their perl coding.

No comments: