in reply to Re: My first attempt at inheritance
in thread My first attempt at inheritance

"Your first routine calls IO::DIR::pl->new, but I don't see any 'new' in IO::dir::pl.

"You *can't rely* on inheritance yet, as you don't have a Blessed Object!"

Not true. Inheritance works on class methods too. Look ma, no blessed objects!

use v5.12; use strict; use warnings; require File::Spec; @File::Spectacles::ISA = "File::Spec"; say File::Spectacles->tmpdir;

The OP's entire problem was that he was trying to rely on IO::Dir::pl's inheritance, before he'd assigned anything to @ISA.

Adding @IO::Dir::pl::ISA = "IO::Dir" to the beginning of the file suffices to fix it. (Though it's probably not the solution I'd use personally.)

Update: sorry - fixed code.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Replies are listed 'Best First'.
Re^3: My first attempt at inheritance
by perl-diddler (Chaplain) on Jun 01, 2013 at 10:18 UTC
    Um...did you try that...doesn't work here...
    > perl -e ' use v5.12; use strict; use warnings; @File::Spectacles::ISA = "File::Spec"; say File::Spectacles->tmpdir;' Can't locate package File::Spec for @File::Spectacles::ISA at -e line +7. Can't locate package File::Spec for @File::Spectacles::ISA at -e line +7. Can't locate object method "tmpdir" via package "File::Spectacles" at +-e line 7.
    Vs. if you put the use in:
    > perl -e ' use File::Spec; use v5.12; use strict; use warnings; @File::Spectacles::ISA = "File::Spec"; say File::Spectacles->tmpdir;' /tmp
    I've always had to put in a 'use' before it would work... But your perl may be different (works without pre-declaring things.)...hmmm.... I'm using 5.16.2...BTW...maybe this is something that changed, though I seem to remember it being around for a while...?? But then I remember the easter bunny just like it was yes...er...scratch that.

    Um... So did you actually try your example? -- didn't work here. Sorry... :-(