#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $h = { 'a' => 1, 'b' => 2, 'c' => 3, }; warn Dumper [ $$h{a}, $$h{x}, $$h{b}, $$h{c} ]; warn Dumper [ keys %$h ]; warn Dumper [ grep {$$h{$_}} qw/a b c x/ ]; # <-- no side effect warn Dumper [ keys %$h ]; #### C:/Perl_524/bin\perl.exe d:/tmp/pm/grep_autovivify.pl $VAR1 = [ 1, undef, 2, 3 ]; $VAR1 = [ 'a', 'c', 'b' ]; $VAR1 = [ 'a', 'b', 'c' ]; $VAR1 = [ 'a', 'c', 'b' ];