package AutoRequire; use 5.006; use strict; no strict 'refs'; use warnings; our $VERSION = substr q$Revision: 1.0$, 9; my %loadable; our $AUTOLOAD; sub import { my $self = shift; foreach (@_) { my $PACKAGE = $_; $DB::single=1; (my $pfile = "$PACKAGE.pm") =~ s#::#/#g; $loadable{$PACKAGE} = 1; my $full_auto = $PACKAGE . "::AUTOLOAD"; *{$full_auto} = sub { my $subname = $AUTOLOAD; my ($pkg,$sub) = $AUTOLOAD =~ / ^ ( \w+ (?: :: \w+)* ) :: ( \w+ ) \z /x; if ( delete $loadable{$PACKAGE} ) { require $pfile; # commenting out this line removes the segfault delete ${$PACKAGE."::"}{AUTOLOAD}; if ($PACKAGE eq $pkg) { print STDERR "This is the branch we execute\n"; goto &$subname; } } } } } 1;