[tpm] Understanding 'use base ...'

Shaun Fryer sfryer at sourcery.ca
Tue Jul 15 08:30:21 PDT 2008


It was pointed out to me by a collegue a month or so ago after he spent
a day tracking down strange inheritance related problems in a code base
we were working on. It may be that there were other peculiarities to the
environment which lead to the problem. I'll have to look into it a bit
deeper I guess. Perhaps if it happens further up the inheritance chain
that might have side effects? Hmm. Well, sorry for any confusion...

Cheers,
    Shaun Fryer

On Mon, Jul 14, 2008 at 06:34:49PM -0400, Uri Guttman wrote:
> that sounds wrong to me. use base just sets @ISA for you. and it will do
> so in the order you put the use base lines. i am not sure if it does
> unshift or push onto @ISA but that is easily determined. why do you
> think that use base does something other than mung @ISA? @ISA is the
> only way perl inheritance works so it has to be munged by use base.
> 
> and that is trivial to show by running a couple of use base calls.
> 
> perl -le 'use base "LWP::Simple" ; use base "Scalar::Util"; print "@ISA\n" '
> LWP::Simple Scalar::Util
> 
> perl -le 'use base "Scalar::Util"; use base "LWP::Simple" ; print "@ISA\n" '
> Scalar::Util LWP::Simple
> 
> so it looks like the first use base is higher priority in @ISA which
> means it does a push.
> 
> uri


More information about the toronto-pm mailing list