I'm trying to introduce a --test option to the script, that would do a "dry run", without actually transferring the file, just printing status messages on every step. Since the majority of the code is the same for test and normal run, I want to use those if, and, or, unless keywords, and I want to keep the code compact. I have a C background, so my code did look like a C program... well, initially it did. But I'm realy impressed with the power of Perl to mangle several statements together like this, and trying to use that.
Now the problem is clear. You have a simple requirement that can be expressed clearly in code. However, giddy with the newly-discovered expressive power of Perl, you're looking for a way to squeeze what you want to say into as small a space as possible.

Don't. It makes code ugly, complicated, and damned near impossible to understand, never mind maintain. It makes people hate Perl programmers and hate Perl. It's a fun game, and can even teach you something about the language, but you should never do it on production code (defined as code you will run more than once).

In addition to which, the specific trick you're trying to use is not allowed. Statement modifiers are limited to one per statement.

If there are better ways to do this, I'm open to suggestions...
ikegami has the right idea:
if ($comment or $test) { $a = 3; print "--> $a\n"; } else { print "no way!\n"; }
By the way, where can I find references to the syntax of those Perl keywords? I tried to search for them, but they aren't functions, and Google promptly omits them from the search criteria...
They are documented in perlsyn.

In reply to Re^3: Complex conditional statements by mrpeabody
in thread Complex conditional statements by bofh_of_oz

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.