Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Pragma usage is lexical, so just by looking at the text of the code, you can determine where strict will apply or not. Since package is not a scope-closer (starting a new package, thus closing the old package, won't start a new lexical scope) the strict scope will run right over it.
use strict; package Strict::Package;
or
package Not::Strict::Yet::Package; use strict; # Now it's a strict package
are almost the same, provided there are no lines between the package and the use line in the second option. (The only difference being that the package declaration itself will not be subject to strict's strictness.) But bear in mind, since the scope of the declaration is lexical, if you declare the strict in another scope, it won't apply. (That is, if you declare strict in another block, loop, eval, file, or subroutine.)
{ use strict; package I::Think::I'm::Strict; } # But I'm really not
Overall, I would say that I would prefer the first one, but I don't think it makes much of a difference. The only reason why I go for the first option is that if I'm going to use strict, I like to say so right away, so I put that declaration right after the shebang. But even if you put it immediately inside the first package of the file, and then went on to define several more packages in that file, it would apply to all of the packages there, but not to the first package statement itself, if that mattered at all.

In reply to Re: order of strict and package by needles
in thread order of strict and package by John M. Dlugosz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-18 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found