Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Location of 'use' statements

by perrin (Chancellor)
on Apr 18, 2003 at 19:10 UTC ( #251511=note: print w/ replies, xml ) Need Help??


in reply to Location of 'use' statements

Number 3 of course! Putting anything before your package statement is just wierd, and pragmas and inheritance are more important than external libraries. I would consider "use constant" a totally different kind of thing and put it after everything else with a blank line above it. (Actually, I would just not use that annoying thing, but that's a different story.)


Comment on Re: Location of 'use' statements
Re: Re: Location of 'use' statements
by demerphq (Chancellor) on Apr 19, 2003 at 10:04 UTC

    (Actually, I would just not use that annoying thing, but that's a different story.)

    I for one would like to hear that story. I don't use them often, primarily for real constants (like OS constants and the like) and things like DEBUG. But I'm curious if theres some trap or zap that I havent quite fallen into that I aught to know about?

    ---
    demerphq

    <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...
      The problem with "use constant" is that the constants are implemented as subroutines. This means that they break (silently) if you try to use them as hash keys, in double-quoted strings, or any other place where barewords are not interpreted as sub calls.

      If you use global variables instead, everyone knows what they are and you avoid these bugs which tend to catch every user of constant at least once.

        This means that they break (silently) if you try to use them as hash keys, in double-quoted strings, or any other place where barewords are not interpreted as sub calls.

        Hmm. *grin* I can't recall being bitten by those things. I've used constants for array indexes on occasion, but never hash indexes. But its good to keep in mind. Thanks.


        ---
        demerphq

        <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-09-03 06:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (35 votes), past polls