my ($class,$file,$h,$load,$package); $class = ''; $file = './auto/AutoReloader/foo.al'; $h = { check => \do { my $v = undef }, checkref => \do { my $v = 1177271972 }, checksub => \sub { package AutoReloader; use warnings; use strict 'refs'; (stat $_[0])[9]; }, file => './auto/AutoReloader/foo.al', function => 'AutoReloader::foo', inner => \sub { package AutoReloader; print 'AutoReloader'; }, outer => 'V: $AutoReloader1' }; $load = sub { package AutoReloader; use warnings; use strict 'refs'; my($class, $package, $file, $h) = @_; delete $INC{$file}; my $ref = eval "package $package; require '${file}'"; return undef if $@; { unless (&Scalar::Util::reftype($ref) and &Scalar::Util::reftype($ref) eq 'CODE') { $ref = \&{$$h{'function'};}; BEGIN {${^WARNING_BITS} = "TUUU\025UUUUUUU\001"} no strict 'refs'; *{$$h{'function'};} = $$h{'outer'} if $$h{'outer'}; } ${$$h{'inner'};} = $ref; my $sub = sub { BEGIN {${^WARNING_BITS} = "TUUUUUUUUUQU\001"} my $cr = $$h{'checkref'}; my $check; $check = ${$$h{'check'};} if defined ${$$h{'check'};}; if (not defined $check) { $check = $AL{'check'}{$class} if defined $AL{'check'}{$class}; } if ($check and ${$$h{'checksub'};} and (my $c = &${$$h{'checksub'};}($file)) != $$cr) { warn "reloading $file" if $Debug; $$cr = $c; &$load($class, $package, $file, $h); } goto ${$$h{'inner'};}; } ; } }; $package = 'AutoReloader'; $AutoReloader1 = bless( sub { package AutoReloader; BEGIN {${^WARNING_BITS} = "TUUUUUUUUUQU\001"} use strict 'refs'; my $cr = $$h{'checkref'}; my $check; $check = ${$$h{'check'};} if defined ${$$h{'check'};}; if (not defined $check) { $check = $AL{'check'}{$class} if defined $AL{'check'}{$class}; } if ($check and ${$$h{'checksub'};} and (my $c = &${$$h{'checksub'};}($file)) != $$cr) { warn "reloading $file" if $Debug; $$cr = $c; &$load($class, $package, $file, $h); } goto ${$$h{'inner'};}; }, 'AutoReloader' ); $h->{outer} = $AutoReloader1;