in reply to detecting an undefined variable
I completely agree with the remarks of haukex, LanX and Athanasius regarding hashes, but if you just gotta do something like this, here's another way:
This is entirely a compile-time solution. Note that the extscale function must be either declared (as above) or defined before it is used. Note also the use of a prototype to achieve the desired effect.c:\@Work\Perl\monks>perl -le "use 5.010; ;; use strict; use warnings; ;; sub extscale (); ;; my $myscale = extscale // 1; print $myscale; ;; sub extscale () { no strict 'vars'; no warnings 'once'; return $scale; } " 1
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: detecting an undefined variable
by LanX (Saint) on Sep 21, 2019 at 15:25 UTC |