(contributed by brian d foy)
-The full answer to this can be found at
-http://cpan.org/modules/04pause.html#takeover
-
The easiest way to take over a module is to have the current
module maintainer either make you a co-maintainer or transfer
the module to you.
}
$match = compare("old McDonald", qr/d.*D/i);
-Notice how C<qr//> allows flags at the end. That pattern was compiled
-at compile time, although it was executed later. The nifty C<qr//>
-notation wasn't introduced until the 5.005 release. Before that, you
-had to approach this problem much less intuitively. For example, here
-it is again if you don't have C<qr//>:
-
- sub compare($$) {
- my ($val1, $regex) = @_;
- my $retval = eval { $val1 =~ /$regex/ };
- die if $@;
- return $retval;
- }
-
- $match = compare("old McDonald", q/($?i)d.*D/);
-
-Make sure you never say something like this:
-
- return eval "\$val =~ /$regex/"; # WRONG
-
-or someone can sneak shell escapes into the regex due to the double
-interpolation of the eval and the double-quoted string. For example:
-
- $pattern_of_evil = 'danger ${ system("rm -rf * &") } danger';
-
- eval "\$string =~ /$pattern_of_evil/";
-
-Those preferring to be very, very clever might see the O'Reilly book,
-I<Mastering Regular Expressions>, by Jeffrey Friedl. Page 273's
-Build_MatchMany_Function() is particularly interesting. A complete
-citation of this book is given in L<perlfaq2>.
-
=item Passing Methods
To pass an object method into a subroutine, you can do this:
(contributed by brian d foy)
Calling a subroutine as C<&foo> with no trailing parentheses ignores
-the prototype of C<foo> and passes it the current value of the argumet
+the prototype of C<foo> and passes it the current value of the argument
list, C<@_>. Here's an example; the C<bar> subroutine calls C<&foo>,
which prints what its arguments list:
By default, your program starts in package C<main>, so you should
always be in some package unless someone uses the C<package> built-in
with no namespace. See the C<package> entry in L<perlfunc> for the
-details of empty packges.
+details of empty packages.
=head2 How can I comment out a large block of Perl code?