in reply to Iterating over an hash while removing keys
Basically:
The following demo is always resetting, but doesn't need to.
DB<41> @h{a..c,A..C} = (1..3,11..13) DB<42> x \%h 0 HASH(0x33bf940) 'A' => 11 'B' => 12 'C' => 13 'a' => 1 'b' => 2 'c' => 3 DB<43> while (my ($k,$v) = each %h ) { delete $h{$k}; print "$k,$v\n +"; delete $h{uc($k)} } continue {keys %h } c,3 a,1 B,12 b,2
Question to follow ;-P
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
*) this was a root post which was re-parented to the later question. Partly because it toook eily more than 15 min to ask, but mainly because I liked the idea to defy causality! ;-)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Iterating over hash while deleting elements
by Eily (Monsignor) on Feb 06, 2020 at 17:02 UTC | |
by LanX (Saint) on Feb 06, 2020 at 17:05 UTC | |
by Eily (Monsignor) on Feb 06, 2020 at 17:07 UTC | |
by LanX (Saint) on Feb 06, 2020 at 17:21 UTC | |
by Eily (Monsignor) on Feb 06, 2020 at 17:29 UTC | |
|