package Array::Map::OO;
sub new {
my $class = shift;
bless [@_], $class
}
sub AUTOLOAD {
my $self = shift;
return if $AUTOLOAD =~ /::DESTROY$/;
my @array;
for ( @$self ) {
eval {
push @array, $_->$AUTOLOAD( @_ );
}
if ( $! ) {
warn $!;
# actually, provide an option
}
}
if ( wantarray ) {
return @array;
} else {
return __PACKAGE__->new( @array );
}
}
Now, if we can get children to return one of these instead of just an array, we can do something like:
my @grandchildren = $root->children->children;
But what about children_and_self? We'll be processing some things twice.
|