# before the loop sub enquote { return { map { qq("$_") => undef } @_ }; } my %attributes=( 'fo:font-style' => enquote( qw(normal italic oblique backslant inherit ) ), 'fo:fontvariant'=> enquote( qw(normal small-caps inherit ) ), 'fo:fontweight' => enquote( qw(normal bold bolder lighter inherit 100 200 300 400 500 600 700 800 900) ), 'fo:visibility' => enquote( qw(visible hidden collapse inherit) ), ); # then, when you're inside the loop: for my $k (keys (%are)) { if ( exists( $attributes{$k} ) ) { if ( ! exists($attributes{$k}{$are{$k}}) ) { print FOUT $errorMessage; } } }