Brian Raven wrote:
According to 'perldoc perlsub' "intent of this feature is primarily to
let you define subroutines that work like built-in functions". For that
reason I have rarely (if ever? - not sure) used them. My advice would be
not to use them unles you actually need your subs to look like builtin
functions.

BTW, for recursion to work with prototypes you need to pre-declare the
subrouting. For example:

use strict;
use warnings;

sub test_sub ($$);

sub test_sub ($$) {
    my $str = shift;
    my $num = shift;
    print "str=$str num=$num\n";
    test_sub $str, $num - 1 unless $num <= 0;
}

test_sub "Hello", 3;


HTH

Prototypes in Perl are not the same as prototypes in other languages.

Hmmm. I'd read perlsub but was thinking of it like a pragma rather than what it is. Effect of PascalVision I guess, even 15 years on.

I still think that the predeclare looks kind of funky to someone not familiar with Perl. As I get older, I'm becoming more conscious that my code needs to be clearly written if I ever want to not be the one maintaining it.

Thanks

Steve
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to