Slightly recoded (omitting the hash ref) and with a dirty trick (copying the hash) it seems to work:
#!/usr/bin/env perl use strict; use warnings; use Data::Dump; my %happy_camper = ( Rambler => 'The Yellow Rose of Texas', Wagon => 'There may be flies on them there guys but there are 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'; my %copy = %happy_camper; foreach ( 1 .. 900000 ) { while ( my ( $k, $v ) = each %copy ) { if ( int( rand 300000 ) == 1 ) { $happy_camper{ ++$newkeys } = 'Shame on you!'; } } } dd \%happy_camper; __END__ karls-mac-mini:~ karl$ ./strange.pl { Caskit => "The Rain in Spain goes mainly down the drain", KEYME001 => "Shame on you!", KEYME002 => "Shame on you!", KEYME003 => "Shame on you!", KEYME004 => "Shame on you!", KEYME005 => "Shame on you!", KEYME006 => "Shame on you!", KEYME007 => "Shame on you!", KEYME008 => "Shame on you!", KEYME009 => "Shame on you!", KEYME010 => "Shame on you!", Lemon => "Love the smell of napalm in the morning", Rambler => "The Yellow Rose of Texas", Skate => "The Quick Brown Fox Jumped Over The Lazy Dogs Back", Wagon => "There may be flies on them there guys but there are no +flies on us", }
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
Furthermore I consider that Donald Trump must be impeached as soon as possible
In reply to Re: To each() their own
by karlgoethebier
in thread To each() their own
by Ancient.Wizard
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |