sub AUTOLOAD { my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::')+2); my $code_ref = File::Samba->can($method); if (!$code_ref) { require Carp; Carp::croak("Undefined subroutine $method called"); } # Create stub functions to avoid calling # AUTOLOAD more than necessary. my $stub = sub { # This only works with methods, # and only if they are non-static. local $_[0] = ident $_[0]; &$code_ref; }; { no strict 'refs'; *$method = $stub; } goto($stub); } #### sub AUTOLOAD { my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::')+2); my $code_ref = File::Samba->can($method); if (!$code_ref) { require Carp; Carp::croak("Undefined subroutine $method called"); } # Don't create stub functions to avoid # clearing perl's method cache repeatedly. # See http://www.perlmonks.org/?node_id=505443 # This only works with methods, # and only if they are non-static. local $_[0] = ident $_[0]; goto($code_ref); } #### sub can { my $p = shift(@_); return UNVERSAL::can($p, @_) || File::Samba->can(@_); }