in reply to Fast lookup for prefixes in hash
my $key = "31456"; # or whatever; my $value = undef; do { $value = $hash{ $key }; # undef if not defined $key = substr( $key, 0, -1 ); } while ( !$value && $key ); # once value is set, this exits with the value # once the key is exhausted, this exists
|
|---|