develooper Front page | perl.perl5.porters | Postings from July 2001

Re: [ID 20010731.072] map vs array of hashes with holes

Thread Previous
From:
Abhijit Menon-Sen
Date:
July 31, 2001 20:47
Subject:
Re: [ID 20010731.072] map vs array of hashes with holes
Message ID:
20010801091719.B480@lustre.dyn.wiw.org
At 2001-07-31 13:09:49, ric@sylvester.Telcom.Arizona.EDU wrote:
> 
> map {if ($_->{port_mac} eq $mac) {$port = ($_->{port})}} @port; [...]
>
>   Modification of a read-only value attempted at poo.tc line 11.

Offhand, I'd say the readonly value is PL_sv_undef, and the attempted
modification is the vivification of $_->{port_mac}.

> I'm not sure if this a bug, or a restriction that isn't apparent to me
> from the documentation.

It isn't a bug, although the error message is certainly misleading. If
you know that your array will have holes in it, check if $_ is defined
before trying to dereference it.

- ams

Thread Previous


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