Re: C style comments?
by KM (Priest) on Aug 08, 2000 at 18:02 UTC
|
my $I_am_some_code = qq{a value};
=cut
Hi, I am a comment.
Wow, now I am a multiline comment!
=cut
sub I_am_more_code {
print $I_am_some_code;
}
The =cut directive will cut text out of code. Also look at perlpod.
Cheers,
KM
| [reply] [d/l] |
|
|
Thanks, thats very helpful. I suppose its about time that I read up some more on POD. So much stuff to learn.... :)
| [reply] |
RE: C style comments?
by jlistf (Monk) on Aug 08, 2000 at 18:07 UTC
|
you can also use a here document. something like:
my $variable = 1;
<<Comment;
la la la
comments comments everywhere
Comment
print $variable;
jeff | [reply] [d/l] |
Re: C style comments?
by Maclir (Curate) on Aug 09, 2000 at 06:08 UTC
|
#!/usr/local/bin/perl -w
#
my $foo;
#=================================#
# This piece of code performs the #
# bar transformation according to #
# the algorithm in Chapter 8 of #
# Knuth. #
#=================================#
sub bar {
local $something = shift;
# warning - tricky bit of code here
# fixed on 9 Aug 2000 by KR to avoid
# possible divide by 0 situation
return 1;
}
# and so on
That is the convention we use here, with most languages.
Make the comments stand out, and be generous with them.
Ken
| [reply] [d/l] |
|
|
| [reply] |
Re: C style comments?
by initself (Monk) on Dec 21, 2005 at 08:11 UTC
|
use Acme::Comment type => 'C++';
| [reply] [d/l] |
Re: C style comments?
by Happy-the-monk (Canon) on Dec 21, 2005 at 13:44 UTC
|
| [reply] |
Re: C style comments?
by AgentM (Curate) on Aug 08, 2000 at 20:01 UTC
|
No wait! There is nothing wrong with an if(0){} block! Perl recognizes code that can never be executed, may print a warning and scrap the code (i.e. not load it). | [reply] |
|
|
Actually, there is something wrong with an if(0){} block: maintainability. As we work on programs and then come back to them months later, we often find that some slick hack that was obvious when we wrote it is difficult to understand when we come back. Further, if you work for a company where others have to maintain your code, they're not going to be too happy about seeing things like if(0){} scattered all over the place. Particularly for inexperienced programmers, it's not exactly intuitive that you'd using that to create a non-executing block.
Cheers,
Ovid
| [reply] |