Prototyping can be useful in Perl. It shouldn't be overused, however. They
can be powerful when trying to make functions that look and feel like
built-ins. Trying to, for example, create a subroutine that looks like map, grep, and
sort is made by prototyping it as (&@) (will pass coderef and an array). If
you want to accept an array and handle it like splice does you can do (\@;@)
(will pass array ref and an optional array).
There are very specific examples found in the manual in perldoc perlsub.
And there is a warning IF the subroutine is declared before you call it.
Prototyping(1,2); #No exception, just a warning
sub Prototyping ($$$) {
print pop;
}
Prototyping 1, 2, 3; #Good job
&Prototyping(1,2); #works, read perldoc perlsub
Prototyping(1); #Death
I'm an advocate of prototyping. I like the power it can display in making
your own functions behave like built-ins. But you can't go crazy with it and
prototype every sub you write. Only do it when it makes your and the
enduser's/maintainer's life easier.
--
-will
http://www.wgunther.tk
(the above message is double rot13 encoded for security reasons)
Most Useful Perl Modules
-strict
-warnings
-Devel::DProf
-Benchmark
-B::Deparse
-Data::Dumper
-Clone
-Perl::Tidy
-Beautifier
-DBD::SQLite
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>