package Exception::Class; use 5.005; use strict; use vars qw($VERSION $BASE_EXC_CLASS %CLASSES); BEGIN { $BASE_EXC_CLASS ||= 'Exception::Class::Base'; } $VERSION = '1.19'; sub import { my $class = shift; local $Exception::Class::Caller = caller(); my %c; my %needs_parent; while (my $subclass = shift) { my $def = ref $_[0] ? shift : {}; $def->{isa} = $def->{isa} ? ( ref $def->{isa} ? $def->{isa} : [$def->{isa}] ) : []; $c{$subclass} = $def; } # We need to sort by length because if we check for keys in the # Foo::Bar:: stash, this creates a "Bar::" key in the Foo:: stash! MAKE_CLASSES: foreach my $subclass ( sort { length $a <=> length $b } keys %c ) {