Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: My first attempt at inheritance

by shmem (Canon)
on May 31, 2013 at 19:02 UTC ( #1036295=note: print w/ replies, xml ) Need Help??


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; } }


Comment on Re: My first attempt at inheritance
Select or Download Code
Re^2: My first attempt at inheritance
by choroba (Abbot) on May 31, 2013 at 19:10 UTC
    Just moving the package definition higher in the file helps. Also, Autodie should probably be autodie.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      Of course it does. But maybe throwing in BEGIN and a pair of curlies has a good side effect on the OP.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1036295]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2014-09-20 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (164 votes), past polls