http://www.perlmonks.org?node_id=670485


in reply to Code style advice: where to put "use" statements?

Since imports happen at a package level any symbols will still be available outside the sub in the same package, so that's not a reason to do it (just as an example why someone possibly might think they want to do it (in a misguided attempt to limit the scope of imports)).

I think I might have done it once or twice when it's a module that's only used in a single sub rather than throughout the code (so you stash it away in that sub rather than in the "global" list of includes at the start of your code), but other than that I'd be biased against it.

Update: Added extra parenthetical in parenthetical. And it looks like I'm not the only one that's done it for a "just used here" notation. Heh.

The cake is a lie.
The cake is a lie.
The cake is a lie.

  • Comment on Re: Code style advice: where to put "use" statements?