package NewPacket; use Packet; # Could have inherited from Packet, but no # reason to. Luckily, this isn't Java or C++. sub newFromPacket { my $class = shift; my $packet = shift; my @fields = @_; # initialize as needed, return object. bless { packet => $packet, fields => \@fields }, $class; } sub process { my $self = shift; } # you could also use __PACKAGE__ here: Packet::addType( qr/^(something)(.*)/, 'NewPacket' ); Packet::addType( qr/^(somethingElse)(.*)/, 'NewPacket' ); # returns true