package Bar;
use Data::Dumper;
use Moose;
sub bar
{
my $arg = shift;
####
if(ref($arg) eq 'ARRAY') {
return map {
$_->bar;
} @{ $arg };
}
####
print "bar\n";
}
package Foo;
use Moose;
sub foo
{
return [(Bar->new)x3]; # what magic do i need to apply here?
}
package main;
####
use autobox ARRAY => 'Bar';
####
Foo->new->foo->bar;
#no more "Can't call method "bar" on unblessed reference"
#because now ->bar is a native method of ARRAYREFs.
#actually all the methods of Bar are native methods on ARRAYREFs now.