
If you've already done programming you know how important it is to sometimes add comments to your code. This may be to explain a block of code, or just a reminder why you did something a particular way.
In any case, in Perl any line beginning with the octothorpe (#) is considered a comment and is non-executable.
For example I usually add a few lines at the beginning of a script to indicate the date, what the script does, and any dependencies it might have. I sometimes use a comment to separate a specific block of code in a script.
# YEARS - newest publication # print dummy paths # draw donut # details of keywords
A string of hash marks is used to separate any subroutines I include at the bottom of a script.
And a handy way to print a bunch of strings is to use the repetition operator x :
my $tab=" "x4; print "\n" . "#"x30 . " All Done! " . "#" x30 . "\n";
That works for a line or few of comments, but you can also add whole blocks of non-executable text much easier.
Perl has something called POD - Plain Old Documentation.
Any line beginning with an equals sign (=) tells Perl to ignore everything from this line down to the next line that begins with =cut!
=detour For example, this text is considered non-executable as a multi-line comment. =cut
See what I mean?
This is an excellent way to include documentation with your Perl program, as it never gets lost or forgotten. Perl uses this in a big way. So much so that there are modules available to pull these blocks of documentation out of modules into several formats.
I use this feature occassionally to 'comment out' a block of code I'm testing or unsure of.