#!/usr/bin/env perl use strict; use warnings; use Subclass::Of "IO::Dir", -as => "My_IO_Dir", -methods => [ read_pl => sub { my $self = shift; warn "Ok We got here.\n"; return undef; }, ]; my $dh = My_IO_Dir->new('.'); while (my $file_name = $dh->read_pl()) { print STDOUT "$file_name\n"; }