in reply to Re: Better ways to make multi-line comments in Perl?
in thread Better ways to make multi-line comments in Perl?
No doubt some monks will be wondering about this "little known operator". My apologies to Abigail if he thinks I'm spoiling the fun.
So let's break it down.
First, we have a plain ol' here-doc, written as
Well and good. But, as Abigail points out, this can trigger a warning. The solution is to do something with the resulting string. In this case, we feed it to a regex binding operator: =~ q>>;<<q This is a multiline comment. q
This uses the single-q quoting operator to make an empty string. This results in a pretty useless regex, but at least we achieve our goal of doing something with the string created by the here-doc.
So we have something which is equivalent to the following (approximately):
In summary, there is no "little known << >> operator"."this is a comment" =~ //;
Abigail++ for the neat trick!
jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.
|
|---|