Perl global variables in strict mode

If you have a sub you want to read a variable from the global scope you can reference it via use vars.

sub foobar { use vars qw($debug); print "$debug is a global var"; }
Leave A Reply
All content licensed under the Creative Commons License