I've been messing around with packages and modules and trying to get variables accessible between them. However, I had a typo which I thought that the "use strict" pragma would have caught. My simple script looks like this:

use strict;

print "Test variable: $not::here\n";

When I run "perl -c" on it, this is perfectly acceptable syntax, however I never tried to "use" the "not" package as indicated here. Why isn't this an error with "use strict"? And is there another way to detect such an error? Should I get something that says I've tried to access a variable from another package which is not in use in the script?

(Using "warnings" in this case tells me that I've used this only once....and that is better, but still isn't good enough...I could use it twice and then that doesn't show up either!)

There are a number of ways to get round strict's requirement that you pre-declare variables. One of them is that you give the variable a fully-qualified name. That means that you give it a name that contains at least one double semi-colon. All off the text before the final double semi-colon in the name is taken as the name of the symbol table that the variable is found in. Therefore your variable $not::there is interpreted as the variable $there in the symbol table 'not'.

As 'strict' does its checks at compile time there is no way for it to know which symbol tables will exist by the time the code is run and therefore it can't give an error for package variables that don't exist.