in reply to To each() their own

Update: I guess I goofed on the problem. Ooops. Sorry. Since, you don't have an each() loop in the Perl source code, I guess there must be something that is not in your Perl source code causing the error, which would I guess mean something in XS code? I am unable to imagine how this can happen otherwise.

I took the pragmatic approach and re-coded the loop to use a foreach() loop over (keys %$happy_camper) instead of trying to get the combined key,val each() iterator to work. I haven't had trouble adding keys with a foreach loop like below. Tested on Perl 5.20 MSWin32.

#!/usr/bin/env perl use strict; use warnings; use Data::Dump qw(pp); EXAMPLE: { my $happy_camper = { Rambler => 'The Yellow Rose of Texas', Wagon => 'There may be flies on them there guys but there ar +e no flies on us', Caskit => 'The Rain in Spain goes mainly down the drain', Skate => 'The Quick Brown Fox Jumped Over The Lazy Dogs Back +', Lemon => 'Love the smell of napalm in the morning' }; my $newkeys = 'KEYME000'; foreach ( 1 .. 900000 ) { foreach my $_key (keys %$happy_camper) { if ( int(rand 300000) == 1 ) { $happy_camper->{ ++$newkeys } = 'Shame on you!'; } } } pp $happy_camper; } exit 0;

Replies are listed 'Best First'.
Re^2: To each() their own
by Ancient.Wizard (Novice) on May 02, 2017 at 12:29 UTC

    I came to the same conclusion. It seems reasonable that if the each() was inside anyone of many CORE/CPAN modules being used that are *.pm (perl source) the message barked would have include the file and line number. It seems reasonable that because this information is not included it comes form a context that cannot provide it. As XS lives in a apace that could be viewed as the layer that bridges both Perl internals to the outside it stands to reason that some parts of this code must use and deal with Lists, arrays, hashes and other things constructs thus arising to the occasion of doing something that smells like an each().