in reply to Scope of variables using strict

In general, my() variables are not visible outside the scope in which they were created. That being said, required.cgi can't see the $TestVar you made in control.cgi. Nor is the $TestVar you made in control.cgi $main::TestVar. It is a lexically scoped variable, and does not belong to a package.

To do what you're trying to do, either send $TestVar as an argument, or make it a package variable:

# control.cgi use vars '$TestVar'; $TestVar = 'test'; # or $main::TestVar = 'test';


japhy -- Perl and Regex Hacker

Replies are listed 'Best First'.
Re: Re: Scope of variables using strict
by dfog (Scribe) on Mar 23, 2001 at 00:05 UTC
    Thanks, that was just the answer to bring everything together for me. It finally just clicked that strict is only checking for variables that were not fully qualified, rather than being defined. That, of course, makes all the difference in the world to the way variables are created.

    Dave