At 12:49 20.05.2001 -0400, you wrote:

>Before I answer your question, I have to ask you to not use subroutine
>prototypes.  9 out of 10 Perl programmers use them incorrectly or don't
>know what they do.
>
>That being said, there are TWO really useful uses:
>
>   sub my_map (&@) {
>     my $code = shift;
>     my @return;
>     push @return, $code->($_) for @_;
>     return @return;
>   }
>
>That makes a function that allows for a naked block as its first argument:
>
>   @results = my_map { $_ * 2 } (1,2,3,4);
>
>And the other use:
>
>   sub my_push (\@@) {
>     my $aref = shift;
>     push @$aref, @_;
>   }
>
>That allows you to send an array to the function BY REFERENCE, without
>typing the backslash when the function is called:
>
>   my_push @foo, 1, 3, 5, 7;

I also like prototyping for its debugging and safety net behavior.  It 
kindly catches erroneous parameter passing.



Aaron Craig
Programming
iSoftitler.com

Reply via email to