package WTF; use strict; use warnings; use Carp; sub define { my $self = shift; my $type = shift || croak "No type name"; my ($parent, $subclass) = (__PACKAGE__, __PACKAGE__ . "\::$type"); my $new = sub { my $self = shift; bless \( my $scalar ), $subclass; }; { no strict 'refs'; @{"${subclass}::ISA"} = ( $parent ); *{"${subclass}::new"} = $new; } warn "Created type: $type\n"; } sub import { my $self = shift; while (@_) { my ($nm, $list) = splice(@_, 0 ,2); __PACKAGE__->define($nm => $list); } } 1;