in reply to Re^3: detecting an undefined variable
in thread detecting an undefined variable

The second method in your original post would work under

    no strict 'vars';
    no warnings 'once';

Indeed, something similar to this will quietly work even with all strictures and warnings enabled if fully-qualified package-global names are used (e.g., $main::scale or its shorthand version $::scale):

c:\@Work\Perl\monks>perl -MData::Dump -le "use strict; use warnings; ;; my $scale = $::scale // 42; print $scale; dd $::scale; " 42 undef
If fully-qualified names are used, Perl is perfectly clear about who's who and what's what although as you say, it can be hard for the programmer to understand the prevailing state of affairs. (The trick of course is that $scale is not the same name as either $main::scale or $::scale.)


Give a man a fish:  <%-{-{-{-<