Tuesday, August 28, 2007

Smart::Comments

Smart comments provide an easy way to insert debugging and tracking code into a program. They can report the value of a variable, track the progress of a loop, and verify that particular assertions are true.

All smart comments start with three (or more) # characters. That is, they are regular #-introduced comments whose first two (or more) characters are also #'s.

use Smart::Comments;
### [] Acquiring data...
for $i (0 .. 100) { ### Processing ==[%]
think_about($i);
}
sub think_about {
sleep 1; # deep ponder
}

the above program would print a cool animated progress bar.

No comments: