in reply to subroutine prototypes effectiveness across files?

With the caveat that I only use prototypes when I want something to act like a built-in operator, require is tripping you up. Since it happens at run-time, it's too late for perl to check the prototypes on existing code. The simplest solution is to wrap your require lines in BEGIN blocks.

Of course, someone will come flying around the corner to tell you not to use prototypes and someone else will say "you should write a module instead", which are both reasonable ideas, if a lot more work.

Replies are listed 'Best First'.
Re: Re: subroutine prototypes effectiveness across files?
by Anonymous Monk on Oct 24, 2003 at 22:52 UTC
    So out of curiosity, what is the mechanism for adding new routines which are to act like built-in functions if parameter checking is desired?

    As it is, prototyping has limited appeal if it is restricted to same file usage.

    Thanks for setting me straight. I'll have to look more in earnest at objects.

      what is the mechanism for adding new routines which are to act like built-in functions if parameter checking is desired?

      Prototyping, as I said.

      As it is, prototyping has limited appeal if it is restricted to same file usage.

      There is no such restriction.

      While I said that require fires too late for perl to do anything with your prototypes, I also gave you a suggestion on how to require your other files in time for perl to check the prototypes on your functions. Give it a whirl; I think you'll find that it works as you expected your first attempt to work.