|Do you know where your variables are?|
Re: using strict setupby nobull (Friar)
|on Apr 16, 2005 at 08:57 UTC||Need Help??|
You are using Perl4 style libraries. If you are just learning Perl5 you may as well not bother with the old Perl4 approach and go directly to the Perl5 module.
See perlmod and
As you become more exeperienced in Perl you'll find the are places where the Perl4 library arroach is still valid.
As for use strict, it should in general be the first non-comment line in every Perl source file. The only common exception to this is the first package directive in a .pm file is often placed before the use strict.
You appear to have completely misunderstood what use strict 'vars' does. It does not prevent you using global variables. It prevents Perl from interpreting every mention of an undeclared variable as an implicit package variable declaration. (You should probably avoid using the term "global variable" to describe package variable as global variable means different things to different people.)
There are two ways to declare a package variable in Perl.
our makes a package variable available in the current lexical scoped. As such if you want to share a variable with a Perl4-style library then you need the our in both the files.
The other way is use vars, and this is only needed in one place. (This is really a special case of a variable being exported by a module).
Update: there's no such man page as perlmodtut - I was probably thinking of perlmodstyle or perltoot. (Thanks to tlm).