Aha. You're not talking about prototyping at all. You're talking about forward declarations. (See also: prototypes don't do what people expect them to do).
A prototype in perl can be specified at a subroutine declaration to indicate special handling of parameters.
A forward declaration is just there to signal to the compiler that a given name is a subroutine that will be defined later: update: the following code does not use prototypes
#!/usr/bin/perl -w
use strict;
sub bla; # a forward declaration
bla; # <--- call the bla routine
sub bla {
print "Bla!\n";
}
If bla is not declared at the <----- point the bareword "bla" will be interpreted as a STRING. That's almost never what you want and that's why strict complains if you comment out the forward declaration.
Note that you can still call bla as bla() without needing to declare sub bla beforehand.
Prototypes are not really related to this, except that in order for them to work they must also be known to the compiler before it compiles the first call, so you can also use them in forward declarations.
|