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!):

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
Printing the  %main:: package namespace hash after the code is run shows autovivification of the variable globally.


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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.