use strict; use warnings; use v5.12; my ( $a, $b, $c, $d ); my %hash = ( 'a' => 'apple', 'b' => 'banana', 'c' => 'cantaloupe', 'd' => 'dice', ); my $n = 1; foreach my $symbol ( keys %hash ) { say "Iteration ", $n++, ": $symbol => $hash{$symbol}"; say "\tExecuting as follows: \$$symbol = \$hash{\$symbol}\n"; eval "\$$symbol = \$hash{\$symbol}"; # <--------- The evil. } foreach my $symbol ( qw/a b c d/ ) { say "\$$symbol now contains ", eval "\$$symbol"; # Once we start the evil it's hard to stop. } #### Iteration 1: c => cantaloupe Executing as follows: $c = $hash{$symbol} Iteration 2: a => apple Executing as follows: $a = $hash{$symbol} Iteration 3: b => banana Executing as follows: $b = $hash{$symbol} Iteration 4: d => dice Executing as follows: $d = $hash{$symbol} $a now contains apple $b now contains banana $c now contains cantaloupe $d now contains dice