Looking for the best way to exit out of a script if a specific scalar is undefined.

Example:
$foo_path = ('/mnt/foo') if ($^O eq "linux"); $foo_path = ('\\\C:\foo.exe') if (($^O =~ /mswin32|nt/i));
I want to be able to write something like:
if undef ($foo_path) { print "\nFOO was not intended to run on OS:$^0\n" exit; }
... but using undef in this way doesn't work. I've googled
"undef" but am still a bit confused. What's the best way
to verify if a scalar has been initialized and exit the script if it hasn't?
Thanks.

In reply to Using UNDEF by neo1491

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.