perl lexicalizes variables, so if you define something within a scope, that variable will not be accessible outside of that scope ...
I think this is quite misleading. It doesn't make any distinction between lexical and package variables. The point should be clearly made that an automatically created or "autovivified" variable (which is what $public_key_type might possibly be; no way to know from the code fragment shown) is a package global and visible (update: and accessible) everywhere. The following example runs with warnings, but of course can only run without strict (and a good thing, too!):
Printing the %main:: package namespace hash after the code is run shows autovivification of the variable globally.c:\@Work\Perl\monks>perl -le "use warnings; ;; while (! $xyzzy || $xyzzy < 5) { ++$xyzzy; } print $xyzzy; ;; print for grep m{ xyzzy \z }xms, keys %main::; " 5 xyzzy
Give a man a fish: <%-{-{-{-<
In reply to Re^2: variable has value but then become empty
by AnomalousMonk
in thread variable has value but then become empty
by Randy_j53
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |