in reply to Need help with clashing method names

Trying using 'base' to inherit methods from another module and avoid automatically importing methods. Better to explicitly to use a complete package path than depend upon exporting. Example:

A::moo(); # explicit and obvious moo(); # can be problematic and because you are unsure of exactly whic +h one you are calling.

There are some packages that export functions, and you should be very selective about those modules. It can very painful to try and debug those situations when you have two modules with the same function name.

Replies are listed 'Best First'.
Re^2: Need help with clashing method names
by ikegami (Patriarch) on Feb 13, 2009 at 14:54 UTC

    Trying using 'base' to inherit methods from another module and avoid automatically importing methods.

    No one said B::moo was a method. For example, B::moo could be Encode::encode

    { package Child; use Base qw( ); use Encode qw( encode ); our @ISA = 'Base'; sub another_method { ... my $x = encode('UTF-16le', $y); ... } } { package Base; sub encode { ... } sub some_method { ... my $c = $self->encode($p); # Can call Encode::encode($self,$p)! ... } } Child->new()->some_method();