First, I thought of something like this:
*Log::Dispatch::warn = *Log::Dispatch::warning;
But I thought, that it doesn't look nice ;) so I changed it to:
*Log::Dispatch::warn = \&Log::Dispatch::warning;
But both threw warnings that Log::Dispatch::warn is "used only once: possible typo..."; And then, based upon the answers from morgon and mr_mischief I thought of
sub Log::Dispatch::warn {
my $self = shift;
$self->warning(@_);
}
tested with:
#!/usr/bin/perl -l
use strict;
use warnings;
package foo;
sub new {
bless {}, shift();
}
sub foo {
my $self = shift;
print "hello @_";
}
package main;
sub foo::bar {
my ( $self ) = shift;
$self->foo(@_);
}
*foo::baz = \&foo::foo;
*foo::buzz = *foo::foo;
my $o = foo->new();
$o->bar('world');
$o->baz('world');
$o->buzz('world');
__END__