in reply to My first attempt at inheritance
The @ISA array does not appear to work as expected.
True. I guess that's because at runtime IO::Dir::pl->new is called before its namespace is set up proper and its @ISA populated. Wrapping that namespace definition into a BEGIN block fixes that.
And you call the method read_pl(), but all you have is read() in IO::Dir::pl.
use strict; use warnings; use autodie; # not Autodie (update) use IO::Dir; my $dh = IO::Dir::pl->new('.'); while (my $file_name = $dh->read_pl()){ print STDOUT "$file_name\n"; } BEGIN { package IO::Dir::pl; use vars '@ISA'; @ISA = ('IO::Dir'); sub read_pl { my $self = shift; warn "Ok We got here.\n"; return undef; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: My first attempt at inheritance
by choroba (Cardinal) on May 31, 2013 at 19:10 UTC | |
by shmem (Chancellor) on May 31, 2013 at 19:15 UTC |