Perl Advent Calendar 2006-12-07

Christmas don't be late

by Jerrad Pierce

Today's module is yet another one of those clever little ditties from the Mad Aussie. The source consists of a measly four statements, though the implementation itself is but a single line of code. Originally named Don't, it now lives in the zany outland of toys and baubles dubbed Acme. Don't does nothing. More specifically it does nothing to blocks of code. It's not a broken code filter, it simply prevents code from being executed. What good is that? Well, perhaps your text editor doesn't support block commenting (or it works poorly). With don't you can now easily comment out large portions of your code for testing. Sure you could use an if with a false condition but use of the special "keyword" don't will make your code clearer as it avoids abusing existing syntax. Of course one could argue don't does so as well, since it uses the deprecated Perl 4 package seperator '. So enjoy the simple beauty of today's module sometime, or don't.

   1 use Acme::Don't;
   3 #The following does nothing
   4 don't{
   5   print "Dear Santa,\n";
   6   printf("I want %i %s", int(1+9*rand), $_) foreach <DATA>;
   7   print "k thx luv janie\n"
   8 }
   9 __END__
  10 ponies
  11 puppies
  12 ipods