in reply to Re: subroutine prototype in Perl
in thread subroutine prototype in Perl

As an example of the misery you may expect if you approach Perl prototypes with the mindset of a C or C++ programmer, consider the code below and see if you can explain what is happening – and then imagine it is embedded in the middle of thousands of lines of code. Note that the code has no errors and throws no warnings.

>perl -wMstrict -le "sub S ($$) { my ($scalar, @array) = @_; return $scalar + $array[0]; } my @ra = (9, 8, 7, 6); print S(3, @ra); " 7