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

That's not prototyping: that's just predeclaring that the subroutine mysub exists. You're explicitly not specifying a prototype there.

You can call any subroutine without parentheses as long as it's been "seen" before:

#!/usr/local/bin/perl -w use strict; sub bla { print "Bla!\n"; } bla;
update: Ironically, a nice way to make the above fail is to use a (wrong) protoype:
#!/usr/local/bin/perl -w use strict; sub bla($) { print "Bla!\n"; } bla; __END__ syntax error at test.pl line 8, near "bla;" Execution of test.pl aborted due to compilation errors.

Replies are listed 'Best First'.
Re^3: The purpose of prototypes in perl subroutines
by jjhorner (Hermit) on Apr 13, 2005 at 15:32 UTC
    It is the same thing. Ask Nat Torkington, as that is what he calls it. Probably pure semantics, but either way, it is considered prototyping.
    J. J. Horner 
    CISSP,CCNA,CHSS,CHP,blah,blah,blah
    

      Just because someone says something doesn't make it true. This isn't just semantics, either.

      Perhaps you give us the reference where you found Nat talking about this sort of prototype (article name or page number would work). IF you are talking about the "Cryptocontext" article, I think you've misunderstood something.

      --
      brian d foy <brian@stonehenge.com>
        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 
        CISSP,CCNA,CHSS,CHP,blah,blah,blah