declare the prototype before the sub is invoked.
perl needs to understand the prototype before you call the sub, otherwise, when it gets to the subroutine declaration it says "I've already been asked to call this sub, but I see it has a prototype... I don't remember if the invocation matched this prototype. I should throw a fatal warning and let the user deal with it".
You can rememdy this by putting your sub declaration before the main body of your program (known as forward declaration), or by using a prototype before the main body, which just looks like :
sub foo ($$);
for more details, see
perlsub and
perldiag.