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

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

Thread Previous | Thread Next
From:
Eric Brine
Date:
January 1, 2010 17:02
Subject:
Re: [perl #69560] misleading warning: Use of uninitialized value in list assignment
Message ID:
f86994701001011702u563805a5re45b865bff87a079@mail.gmail.com
On Fri, Jan 1, 2010 at 7:59 PM, Eric Brine <ikegami@adaelis.com> wrote:

> On Fri, Jan 1, 2010 at 7:15 PM, Dave Mitchell <davem@iabyn.com> wrote:
>
>> On Fri, Jan 01, 2010 at 05:42:57PM -0500, Eric Brine wrote:
>> > I agree that "list assignment" is correct, but why does the warning say
>> line
>> > 2?
>>
>> Because perl currently only records line numbers per statement, not per
>> op
>
>
> I realize that, but it doesn't explain the difference between
>
> >perl -lw
>
> my %h = map {
>    my $x;
>    (undef, undef)
> }
> ^Z
> syntax error at - line 4, at EOF
> Execution of - aborted due to compilation errors.
>
> >perl -lw
> my %h = (
>
>    (undef, undef)
> );
> ^Z
> Use of uninitialized value in list assignment at - line 1.
>
> The assignment didn't move, so why did the warning?
>
>
Can you tell I'm tired? I recreated the test I ran the test earlier a
"little" too fast. Here's what I should have said:

I realize that, but it doesn't explain the difference between

>perl -lw
my %h = map {
   my $x;
   (undef, undef)
} 1;
^Z
Use of uninitialized value in list assignment at - line 2.

and

>perl -lw
my %h = (

   (undef, undef)
);
^Z
Use of uninitialized value in list assignment at - line 1.

The assignment didn't move, so why did the warning?


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