No, this is not an opportunity for everyone to evaluate my behavior. It's my's behavior that is under the microscope here.

All bad jokes aside, I was playing around with the trinary operator and was trying to do what I guess you could dynamic variable declaration. For what purpose? I don't know. I just wanted to see if I could do it.

Basically what I was trying to do was:

((shift @ARGV) ? $foo : $bar) = "Hello";
So whether or not there is an argument to the script would decide which variable, $foo or $bar, would be declared.

It works fine as is. But if I try to declare with my while using strict, everything falls apart and I get an error.

use strict; my ((shift @ARGV) ? $foo : $bar) = "Hello"; # Can't declare null operation in "my" at trinary.pl...
So I suppose a null operation is one in which no value is returned, which makes sense because why would you use my to declare nothing.

So I'm wondering why this is considered a null operation. The trinary should return one value or the other, in the case either $foo or $bar. The only thing I could think of is that b/c strict is in effect, $foo and $bar do not are evaluated before being declared with my and so technically don't exist. But then I wondered why that didn't through a Global symbol error. And besides that, my behaves the same way and throws the same error whether I use strict or not.

Anyway, I'm at a loss. Any ideas?




dsb
This is my cool %SIG

In reply to my behavior with "NULL" declarations by dsb

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.