No, the expression is  10, 20 and it as a whole is evaluated in scalar context

Obvious mistakes (from Useless use of %s in void context )

$foo = 1, 2;
Useless use of a constant (2) in void context at -e line 1 (#1)

assignment(=) binds tighter than comma(,) so $foo is 1

$ perl -MO=Deparse,-p -e " $foo = 1, 2; " (($foo = 1), '???'); -e syntax OK
$one, $two = 1, 2;
Useless use of a variable in void context at -e line 1 (#1)

$ perl -MO=Deparse,-p -e " $one, $two = 1, 2; " ($one, ($two = 1), '???'); -e syntax OK
Another obvious one: $one, $two = foo();
Useless use of private variable in void context at -e line 1 (#1)

$ perl -MO=Deparse,-p -e " sub foo { 1, 2 } $one, $two = foo(); " sub foo { (1, 2); } ($one, ($two = foo())); -e syntax OK

Since the behavior of comma operator in list/scalar context is well defined,
since the behaviour of a list in scalar/list context is well defined (see If you believe in Lists in Scalar Context, Clap your Hands ),
perl doesn't warn about : $two = foo();
because it is predictable/guaranteed/you're expected to know what it means

 sub foo{1,2}  ($f)= foo(); is like  ($f) = (1,2); # no warn, $f is 1

 sub foo{1,2}  $f = foo(); is like  $f = (1,2); # no warn, $f is 2
perl won't warn you, scalar context guarantees rightest most(last), list context guarantees leftest most (first)


In reply to Re^3: no expected 'Useless use of a constant in void context' warning for expression in return statement by Anonymous Monk
in thread no expected 'Useless use of a constant in void context' warning for expression in return statement by ed_hoch

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.