in reply to Re^5: Where and when you should place 'use module;'?
in thread Where and when you should place 'use module;'?

It is file scoped if it is not used within a package -- I tested this.

That doesn't make any sense. You're almost always within a package. Can you show us how you tested this?

Update: added clarification. Thanks Perl Mouse!

  • Comment on Re^6: Where and when you should place 'use module;'?

Replies are listed 'Best First'.
Re^7: Where and when you should place 'use module;'?
by Perl Mouse (Chaplain) on Oct 12, 2005 at 15:36 UTC
    You're always within a package.
    No, you are not.
    package; print __PACKAGE__; __END__ Use of "package" with no arguments is deprecated at ... Use of uninitialized value in print at ...
    From perldoc -f package:
    If NAMESPACE is omitted, then there is no current package, and all identifiers must be fully qualified or lexicals. However, you are strongly advised not to make use of this feature. Its use can cause unexpected behaviour, even crashing some versions of Perl. It is deprecated, and will be removed from a future release.
    Although you shouldn't, you can be outside of any package.
    Perl --((8:>*
Re^7: Where and when you should place 'use module;'?
by Moron (Curate) on Oct 12, 2005 at 15:27 UTC
    Well, I wasn't counting &main as a package - it certainly wasn't explicitly declared as one.

    -M

    Free your mind

      Well, main works just like any other package (and why you put & in front of it is beyond me). You still haven't shown us this test code you used.