To amplify a little on what others have said - and this is not said to evade your question - you should NOT be doing what your trying to do, which is sharing varibles across files of a project. To do that they must be globals, and that way lies madness.
To repeat what others have said, data sent back and forth should be done by passing parameters from the calling to the called (which will usually be transferrred into lexicals within the sub by something like my ( $p1, $parm2, $etc, ) = @_; and returning values from the called to calling.
By making the file with the subs in it a module, you avoid namespace pollution, which is to say that if the subroutines in a file need to share variables with each other, they are still separate from variables you have inadvertently named the same thing in other modules or in your main program.
And to answer your last question, use strict;
works on a lexical scope, which is to say the scope is between the ineermost containg braces, or, at most, the whole of the file, so yes, every file needs use strict.Oh, and these 2 files do NOT work as given in the absence of use strict, if you think they do, you're confused. It is the scoping of the "my" variable that prevents the scripts from working, not the use of strict.
--Bob Niederman, http://bob-n.comIn reply to Re: 'use strict;' between libraries
by bobn
in thread 'use strict;' between libraries
by Massyn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |