Perl Style: The Art of Commenting Code

  • Explain what the code does, don’t just perl2englishify.
  • Eschew gaudy block banners.
  • Use comments in regexes with /x.
  • Comment entire blocks, not single lines.
  • `Comments on data are usually much more helpful than on algorithms.’ (Rob Pike)
  • `Basically, avoid comments. If your code needs a comment to be understood, it would be better to rewrite it so it’s easier to understand.’ (Rob Pike)

Forward to On the Naming of Names (Form)
Back to Defensive Programming
Up to index

Copyright © 1998, Tom Christiansen All rights reserved.



Something wrong with this article? Help us out by opening an issue or pull request on GitHub