use Object::Import $object;
foo(@bar); # now means $object->foo(@bar);
####
{
my $object = Foo::Bar->new();
import Object::Import $object; # Make all methods of $object available as functions
}
####
#!perl
use strict;
use warnings;
package Foo::Bar;
sub frobnitz {
print "frobnitz in " . __PACKAGE__ . "\n";
};
package Foo::Whatever;
use strict;
use warnings;
require Object::Import;
sub frobnitz {
print "frobnitz in " . __PACKAGE__ ."\n";
};
frobnitz();
{
local *Foo::Whatever::frobnitz;
my $object = {};
bless $object => "Foo::Bar";
Object::Import->import( $object, list => ['frobnitz'], nowarn_redefine => 1 ); # Make all methods of $object available as functions
frobnitz(); # call $object->frobnitz();
}
frobnitz();
__END__
frobnitz in Foo::Whatever
frobnitz in Foo::Bar
frobnitz in Foo::Whatever