or the values w/o autovivification with map:@my_filtered_keys = grep {exists $x{$_} && $x{$_} =~ /Yeah hoo!/} 1..1 +0;
Here is an example:@my_filtered_vals = map {exists $x{$_} && $x{$_} =~ /Yeah hoo!/ ? $x{$ +_} : ()} 1..10;
For more on autovivification see: Autovivification : What Is It and Why Do I Care? by by Uri Guttman.#!/usr/bin/perl -wT use strict; my %x = ( 5 => 'a', 6 => 'b', 7 => 'Yeah hoo!', 8 => 'd', 9 => 'I said, Yeah hoo!', 10 => 'f' ); print "K:$_\n" for grep {exists $x{$_} && $x{$_} =~ /Yeah hoo!/} 1..10 +; print "V:$_\n" for map {exists $x{$_} && $x{$_} =~ /Yeah hoo!/ ? $x{$_ +} : ()} 1..10; print "X:$_\n" for keys %x; __END__ =head1 OUTPUT K:7 K:9 V:Yeah hoo! V:I said, Yeah hoo! X:7 X:8 X:9 X:10 X:5 X:6
-Blake
|
|---|