Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Subs (Placement when Prototyping)

by Jazz (Curate)
on Mar 25, 2002 at 18:55 UTC ( #154177=note: print w/ replies, xml ) Need Help??


in reply to Placement of Subs

On a side note...

If you use prototypes and the sub appears on the bottom (or after the invocation), the prototype will not work as intended. You'll get a "main::subroutine called too early to check prototype" warning and the prototype will not/cannot be checked. When using prototypes, you'll need to either place the sub before its invocation or declare the sub and its prototype:

sub prototest($); # declare sub and prototype prototest( 4 ); # dies if no param or more than 1 param is passed sub prototest($){ print '1, 2, 3, ', @_; }
-or-
sub prototest($){ print '1, 2, 3, ', @_; } prototest( 4 ); # dies if no param or more than 1 param is passed


Comment on Re: Subs (Placement when Prototyping)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://154177]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2014-09-22 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (178 votes), past polls