in reply to Re^2: Best practices - if any?
in thread Best practices - if any?
how should I originally declare variables which spans to global scope if "our" is not global enough?
our is lexically scoped, and files included via require and friends have their own implicit lexical scope (so you'd need to redeclare your our variables).
You might also declare your global package variables using use vars in order to share them across files with strictures enabled. As another alternative, just fully qualify every occurrence of a global variable — as long as they're in the main namespace, that would simply be something like $::foo. The advantage of the latter approach is that they're immediately evident, and that the required additional typing helps to keep them at a minimum :)
That said, think twice before you do so! What is the real idea behind splitting the code? You say "putting couple of big subs to a safe place", but why are they unsafe in their original place? If modularisation/reuse is the idea, why not create proper modules? Also, having to share many variables across different files typically is an indication of bad design in the first place...
|
|---|