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

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

Thread Previous | Thread Next
Eirik Berg Hanssen
April 23, 2018 14:25
Re: [perl #133143] Warning when list assignment RHS is a scalar
Message ID:
On Mon, Apr 23, 2018 at 3:53 PM, Ed Avis <> wrote:

> This is probably a mistake:
>     ($foo, $bar) = $baz;
> In my case it usually means that I wanted @{$baz} instead.
> For other programmers there might be some other reason.
> But surely it cannot be intentional.

  Oh, but it can.  You never know what other programmers might do

> A compile-time warning should be given when an assignment statement
> has a list of two or more items on the LHS, and the RHS is a scalar
> variable expression that begins with a $ sign.

  Sounds like this will break (well, start warning) on the common (quick
and dirty) slurp idiom:

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

  .. and that's just off the top of my head.

  Do we really want "style" warnings on correct and intentional code?


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