New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing warning 'scalar value better written as...' when using reference #16277
Comments
From @epaCreated by @epa% perl -wE '@x = (1, 2, 3); say @x[1]' The second use should also make a warning, along the lines of Scalar value @$x[1] better written as $x->[1] Perl Info
|
From @xsawyerxOn 11/24/2017 12:27 PM, Ed Avis (via RT) wrote:
I think that's a preference in style. While I personally dislike the The warning for "scalar value better written as" refers to the context @foo[ bar() ] = baz(); # List context So it's better to warn here because it's likely not what you wanted if |
The RT System itself - Status changed from 'new' to 'open' |
From @SmylersSawyer X <xsawyerx@gmail.com> writes:
That context difference still applies with references: @$foo[0] = qw<first middle last>; # 'first' The matter of style is that the scalar context one can also be written: $$foo[0] = qw<first middle last>; # 'last' |
From @epaSawyer X, thanks for your reply. If I understand you correctly, you say that the warning is intended for the use of @x[1] as an lvalue. What I do not understand is why it makes sense to treat @$x[1] differently. |
From Eirik-Berg.Hanssen@allverden.noOn Mon, Nov 27, 2017 at 10:50 AM, Smylers <smylers@stripey.com> wrote:
So, a less confusing warning would be: "Scalar value @$x[1] better Or for a more thorough approach: "Scalar value @$x[1] better written as Eirik <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> |
From @xsawyerxOn 11/27/2017 02:31 PM, Eirik Berg Hanssen wrote:
Make it ${$x}[1] and you have got yourself a deal. :) |
Migrated from rt.perl.org#132502 (status was 'open')
Searchable as RT132502$
The text was updated successfully, but these errors were encountered: