from perldoc perlop:
C-style Logical Defined-Or Although it has no direct equivalent in C, Perl's "//" operator + is related to its C-style or. In fact, it's exactly the same as " +||", except that it tests the left hand side's definedness instead o +f its truth. Thus, "$a // $b" is similar to "defined($a) || $b" (exc +ept that it returns the value of $a rather than the value of "defined($a +)") and yields the same result as "defined($a) ? $a : $b" (except that +the ternary-operator form can be used as a lvalue, while "$a // $b" cannot). This is very useful for providing default values for variables. If you actually want to test if at least one of $a +and $b is defined, use "defined($a // $b)". The "||", "//" and "&&" operators return the last value evaluat +ed (unlike C's "||" and "&&", which return 0 or 1). Thus, a reason +ably portable way to find out the home directory might be: $home = $ENV{HOME} // $ENV{LOGDIR} // (getpwuid($<))[7] // die "You're homeless!\n"; In particular, this means that you shouldn't use this for selec +ting between two aggregates for assignment: @a = @b || @c; # this is wrong @a = scalar(@b) || @c; # really meant this @a = @b ? @b : @c; # this works fine, though As more readable alternatives to "&&" and "||" when used for co +ntrol flow, Perl provides the "and" and "or" operators (see below). +The short-circuit behavior is identical. The precedence of "and" a +nd "or" is much lower, however, so that you can safely use them after a + list operator without the need for parentheses: unlink "alpha", "beta", "gamma" or gripe(), next LINE; With the C-style operators that would have been written like th +is: unlink("alpha", "beta", "gamma") || (gripe(), next LINE); Using "or" for assignment is unlikely to do what you want; see +below.

print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

In reply to Re: Strange syntax question by Utilitarian
in thread Strange syntax question by gri6507

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.