http://qs321.pair.com?node_id=93473


in reply to Function Prototypes

When you define your subroutine, it does not require parenthesis. Like so:
# Sub definition sub usage { blah... } # Calling the sub usage();
You only want to use parenthesis if you want to restrict the parameters which may be sent to it. In this instance, that may be the case, but it seems as if you may have done it by accident ;-) If you do choose to use these parenthesis in the sub definition, it's called a prototype.
-Eric

Updated: As currently written, your program doesn't run because you call the subroutine using:
usage();
When you use a prototype to forbid parameters, you cannot use parenthesis in the subroutine call. You can just use:
usage;
Now, for someone better with prototypes then myself -- I know this works, because I double checked with the Camel Book before posting. But I don't know _why_ this is the case. On page 226 of Camel 3, it says that with the prototype sub mytime(), one should call it using mytime.

However, going back a few pages to page 222, it talks about how to call subroutines, and what the differences are. It claims that saying foo(); passes a null list to the sub. It then says that using foo; is the same as foo();. Now, that can't be 100% true, if the one won't work with prototypes, but the other does. Does someone know how this is really working?