develooper Front page | perl.perl5.porters | Postings from April 2018

[perl #133143] Warning when list assignment RHS is a scalar

Thread Previous | Thread Next
Ed Avis via RT
April 23, 2018 14:31
[perl #133143] Warning when list assignment RHS is a scalar
Message ID:
On Mon, 23 Apr 2018 07:25:37 -0700, wrote:

>  my $text = do { local (@ARGV, $/) = $filename; <> } ;

The warning I proposed wouldn't fire there because the LHS is not a simple list of scalars.

This example and the earlier one have in common that they are both declarations as well as assignments.
One is with 'my', one with 'local'.  So how about cutting back the warning a bit so that only pure assignments, not declarations, fire?

    ($foo, $bar) = $s;     # warns
    my ($foo, $bar) = $s;  # does not warn

The second case is something you might write as a more concise way of declaring two variables and assigning one of them.  Personally I'm not a fan, but I recognize that it might better be handled by a linter such as perlcritic, where people can more easily plug in their own opinions.

via perlbug:  queue: perl5 status: open

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About