Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re^5: The purpose of prototypes in perl subroutines

by jjhorner (Hermit)
on Apr 13, 2005 at 17:41 UTC ( #447532=note: print w/replies, xml ) Need Help??

in reply to Re^4: The purpose of prototypes in perl subroutines
in thread The purpose of prototypes in perl subroutines

Okay, Page 20, "Computer Science & Perl Programming", edited by Jon Orwant, Chapter 3, article title is Perfect Programming. I'm not making this up: Quote: When it's in effect, you can't use the bareword style of calling subroutines with no arguments (e.g. $result = mysub;) unless the subroutine was declared before its use, either with a prototype or with the subroutine definition itself. EndQuote:
use strict 'subs'; print count; # an error with use strict 'subs' sub count; # prototyping count() is sufficient print count; # Not an error because Perl now knows about count()
J. J. Horner 

Replies are listed 'Best First'.
Re^6: The purpose of prototypes in perl subroutines
by brian_d_foy (Abbot) on Apr 13, 2005 at 18:12 UTC

    The part that you called "prototyping" before is just the subroutine's forward definition. He gives two things there that get around 'use strict', and the one you used wasn't the one with prototypes.

    The very first example in perlsub tells you which one you used:

    To declare subroutines: sub NAME; # A "forward" declaration. sub NAME(PROTO); # ditto, but with prototypes
    brian d foy <>

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2023-05-30 17:12 GMT
Find Nodes?
    Voting Booth?

    No recent polls found