develooper Front page | perl.perl5.porters | Postings from January 2010

Re: [perl #69560] misleading warning: Use of uninitialized valuein list assignment

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
January 1, 2010 11:49
Subject:
Re: [perl #69560] misleading warning: Use of uninitialized valuein list assignment
Message ID:
20100101194926.GA2878@iabyn.com
On Sat, Oct 03, 2009 at 11:02:56PM -0700, andrew@pimlott.net (via RT) wrote:
> The following program generates a perplexing warning:
> 
>     % perl -w
>     my %h = map {
>         my(@x) = (undef, undef);
>     } 1;
>     Use of uninitialized value in list assignment at - line 2.
> 
> What's wrong with the list assigment at line 2?  Nothing!  It's really
> complaining about the hash assigment at line 1.  Tell me what's really
> upsetting you, perl, don't blame something else!

Ah, no!

There are only two types of assignment: scalar and list, and the warning
is correct. You can see the same warning in the simplified code:

    $ perl -we 'my %h =(undef,undef)'
    Use of uninitialized value in list assignment at -e line 1.

-- 
Fire extinguisher (n) a device for holding open fire doors.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About