in reply to Java Style Interface Objects?

Maybe the folllowing will help you get on the right path. It would be nice if you didn't have to call enforce_interface in all the child classes...
use strict; use warnings; my $bar = Bar->new; #------------------------ package Foo; # implement these in the child class # sub bing { } # sub bang { } # sub bong { } sub enforce_interface { my $self = shift; for ( qw/bing bang bong/ ){ # require these methods die "$_ not implemented" unless $self->can( $_ ); } } 1; #------------------------ package Bar; sub new { return bless {}; } # don't implement bing sub bang { } sub bong { } use base qw/Foo/; __PACKAGE__->enforce_interface; 1;
and when run:
bing not implemented at test.pl line 17.