(Update: Sorry for the confusion. Until Liz' update about the fact that she was talking about "m ($v) =..." in the second half of her reply, I mistook her reply to be talking about the ordinary "my ($v) = 'a';".)

Hi Liz,
I don't think "my ($v) = '';" is equivalent to "$_ =~ m/$var/ = '';" and throwing a warning.
(cmd.exe has different shell quoting!) %perl -w -Mstrict -e "my ($v) = '';" (no warnings)
And thus:
%perl -w -Mstrict -e "my ($v) = 'a'; print $v;" a
which parses in my head as 'string is assigned to first element of the left hand side list'. I can't argue with the exact concepts applied by the interpreter because I forgot most about the weirder rules of context including lvalue stuff. But this seems to support the above:
%perl -w -Mstrict -e "my ($v,$s) = 'a'; print $v, $s;" aUse of uninitialized value in print at -e line 1.
Still, string being assigned to first element of the left-hand side list. Same for lists on the right-hand side. (Which would be common usage in contrast to the above weirdness.)
%perl -w -Mstrict -e "my ($v,$s) = ('a'); print $v, $s;" aUse of uninitialized value in print at -e line 1.
Good. As expected. Same goes for two-element lists on the rhs.
%perl -w -Mstrict -e "my ($v,$s) = ('a', 'b'); print $v, $s;" ab
And the ',' operator has lower precedence than '=', so we get a 'useless use of a constant' error.
%perl -w -Mstrict -e "my ($v,$s) = 'a', 'b'; print $v, $s;" Useless use of a constant in void context at -e line 1. aUse of uninitialized value in print at -e line 1.
Hope this clarified things a little.

In reply to Re: Re: declaration of variables by tsee
in thread declaration of variables by Murcia

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.