For my Array::AsHash module, there's an obvious feature that I just didn't think about: allowing subrefs.
$hash->values( sub { ucfirst } };
You might even want that for the keys since the can be references:
my @parents = $hash->keys( sub { $_->parent } );
Well, duh!
I really like that. It would be very useful way of filtering.
It would be slick to use in an each too. Very ruby-ish.
Or something similar to your example:while ( my ($key, $value) = $array->each( sub {/^foo/ } ) {
# iterate over array like a hash
}
while ( my ($key, $value) = $array->each( sub { ucfirst } ) {
# iterate over array like a hash
}