Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Why does this dump core?

by danger (Priest)
on Dec 11, 2001 at 15:34 UTC ( [id://130909]=note: print w/replies, xml ) Need Help??


in reply to Why does this dump core?

This is likely related to this change in 5.6 (from perldelta):

=head2 delete(), each(), values() and hash iteration are faster The hash values returned by delete(), each(), values() and hashes in a list context are the actual values in the hash, instead of copies. This results in significantly better performance, because it eliminate +s needless copying in most situations.

Previously, only copies were used, which meant that foreach-aliasing didn't really alias into the real hash values:

my %hash = (name => 'andrew', beer => 'Ale'); foreach my $KV (%hash) { print ">>$KV<<\n"; $hash{$KV} = 'Dark Ale' if $KV eq 'beer'; } __END__ # with 5.00503: >>name<< >>andrew<< >>beer<< >>Ale<< # with 5.6.1 >>beer<< >>Dark Ale<< >>name<< >>andrew<<

As you can see, with 5.005, even after we've changed the value for the key 'beer', we still get the old value because it was a copy. In 5.6 we get the new value because it is an alias into the hash. Now, in your situation, after deleting the key '*test' the next iteration involves an alias to a non-existing value and this is causing a problem for perl (which with -w gives "attempt to free unreferenced scalar", and a segfault otherwise).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://130909]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-25 22:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found