my %derived = listOfDerivedClasses( 'Element' ); while( ) { my( $type ) = m[...]; die "Derived type $type not available" unless exists $derived{ $type }; push @instances, $type->new(); } #### while( ) { my( $type ) = m[...]; my $inst; eval{ $inst = $type->new(); 1 }; die "Derived type $type not available:'$@'" if $@; push @instances, $inst; }