asinghvi has asked for the wisdom of the Perl Monks concerning the following question:

My program looks like this.

$var1 ... $var2... $var3 ... sub get_vars { local (*variables) = *main::; #-- Some checking on certain variables }

When I call get_vars before defining $var1, $var2, $var3, then %variables does not contain them.
When I call get_vars after defining $var1, $var2, $var3 then %variables has them. Isn't *variables reading *main:: at compile time. What am I missing?