# map{}' on the last key is ok. my $href = { key1 => { subkey1 => "Defined first is OK", subkey2 => map{s/\r?\n\Z/(munched)/;$_} (${^__}=< EOT }, }; # This explodes... # map{}' ing, then defining another key leads to a runtime error. eval { $href->{key2} = { subkey1 => map{s/\r?\n\Z/(munched)/;$_} ($ {^__}=< EOT subkey2 => "Kaboom !", }; }; if ($@) { ($href->{key2}->{subkey1} = $@) =~ s/\r?\n\Z//; $href->{key2}->{subkey2} = "Set after eval"; $@ = undef; }