Dear Initiate,

I'm glad we've been of help, and so quickly, with your first foray into the Monastery.

In your posts, you should look at the available markup. I know you already figured out to use explicit paragraph markers, which is something that often trips up first-timers. The next thing to know is the <code> tag, around your code items and preformatted listings.

You can always go back and edit your post. So you could, if you wanted to practice at it, insert the code tags and fix your typo (missing 'f').

Yes, undef is an action, not a test. The test is defined. So you could write unless (defined $A) {...}

Your final line could also be written the other way around:

&ChooseLocation unless @MyServers;
which has its advantages. Besides the lack of braces and parens, think about how it flows linguistically, once you get used to the idea. You see the action up front. The rest of it, "oh, skip that step if it's not applicable" is off to the side, not the main part of the statement. The core logic reads cleaner.

Also, know that you are testing for an empty array, not defined-ness. I'm pretty sure that a named array variable can't test as undef itself. It can hold any number of elements, some of which may be undef. But itself is empty, still existing as a container.

Oddly enough the documentation (undef) shows an example of undef'ing an array, but doesn't say what it means. Meanwhile testing for definedness on arrays doesn't work, and used to mean something a bit different.

—John


In reply to Re^3: Global var's that don't hold between subroutines by John M. Dlugosz
in thread Global var's that don't hold between subroutines by Durf182

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.