in reply to Re^2: To be, or not to be, a package? That is the question
in thread To be, or not to be, a package? That is the question

As Fletch said, a namespace is not the same as a lexical scope...

This is important to keep in mind if you merge several modules (.pm files) into one file — for easy distribution, or whatever. Forgetting to put extra braces around each original file / package can introduce nasty subtle bugs... (in particular if the modules are coded sloppily, with lots of global vars, no strictures, etc.).

The behavior is mentioned in the package docs, btw:

(...) A package statement affects only dynamic variables--including those you've used local on--but not lexical variables, which are created with my.

Replies are listed 'Best First'.
Re^4: To be, or not to be, a package? That is the question
by Bloodnok (Vicar) on Dec 04, 2008 at 14:47 UTC
    Following Fletch and zentaras replies, I had a look at some of my (really) old code where I vaguely remembered last utilizing multiple packages in one file ... to find I'd used braces round all package(s) - no wonder I hadn't encountered the problem 'til now.

    A user level that continues to overstate my experience :-))