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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.