Missing Features

Ovid on 2007-11-27T11:38:14

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!


Great Idea, How about?

Lecar_red on 2007-11-27T20:07:13

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.

while ( my ($key, $value) = $array->each( sub { /^foo/ } ) {
    # iterate over array like a hash
}
Or something similar to your example:

while ( my ($key, $value) = $array->each( sub { ucfirst } ) {
    # iterate over array like a hash
}