in reply to Hashes of arrays problem

Having parenthesis after the sub name:

sub foo() { ... }

Tells perl that you want to prototype the parameters that the subroutine will expect. In this case empty parens indicate that the funciton should not take any parameters.

For example, the following code:

use strict; sub foo() { my $param = shift; print "Param: [$param]\n"; } foo; foo(1);

Will result in the following error:

$perl proto.pl Too many arguments for main::foo at proto.pl line 11, near "1)" Execution of proto.pl aborted due to compilation errors.

Line 11 is the function call foo(1);. It is an error because the prototype indicates that the function should not accept any parameters.

This is discussed in:

perldoc perlsub

It's a pretty common mistake for those of us that came from the C/C++ world.


"Look, Shiny Things!" is not a better business strategy than compatibility and reuse.