$is_epoc = $^O eq 'epoc';
$is_vms = $^O eq 'VMS';
$is_macos = $^O eq 'MacOS';
- $VERSION = '5.64';
+ $VERSION = '5.64_01';
}
AUTOLOAD {
goto &$sub;
}
-sub can {
- my ($self, $method) = @_;
-
- my $parent = $self->SUPER::can( $method );
- return $parent if $parent;
-
- my $package = ref( $self ) || $self;
- my $filename = AutoLoader::find_filename( $package . '::' . $method );
- local $@;
- return unless eval { require $filename };
-
- no strict 'refs';
- return \&{ $package . '::' . $method };
-}
-
sub find_filename {
my $sub = shift;
my $filename;
if ( @_ and $_[0] =~ /^&?AUTOLOAD$/ ) {
no strict 'refs';
*{ $callpkg . '::AUTOLOAD' } = \&AUTOLOAD;
- *{ $callpkg . '::can' } = \&can;
}
}
no strict 'refs';
- for my $exported (qw( AUTOLOAD can )) {
+ for my $exported (qw( AUTOLOAD )) {
my $symname = $callpkg . '::' . $exported;
undef *{ $symname } if \&{ $symname } == \&{ $exported };
*{ $symname } = \&{ $symname };
unshift @INC, $dir;
}
-use Test::More tests => 22;
+use Test::More tests => 17;
# First we must set up some autoloader files
my $fulldir = File::Spec->catdir( $dir, 'auto', 'Foo' );
EOT
close(FOO);
-open(BAR, '>', File::Spec->catfile( $fulldir, 'bar.al' ))
- or die "Can't open bar file: $!";
-print BAR <<'EOT';
-package Foo;
-sub bar { shift; shift || "bar" }
-1;
-EOT
-close(BAR);
-
open(BAZ, '>', File::Spec->catfile( $fulldir, 'bazmarkhian.al' ))
or die "Can't open bazmarkhian file: $!";
print BAZ <<'EOT';
is( $foo->foo, 'foo', 'autoloaded first time' );
is( $foo->foo, 'foo', 'regular call' );
is( $result, \&Foo::foo, 'can() returns ref to regular installed sub' );
-$result = $foo->can( 'bar' );
-ok( $result, 'can() should work when importing AUTOLOAD too' );
-is( $foo->bar, 'bar', 'regular call' );
-is( $result, \&Foo::bar, '... returning ref to regular installed sub' );
eval {
$foo->will_fail;
# autoloaded filename.
'foo' =~ /(\w+)/;
-is( $foo->bar($1), 'foo', 'autoloaded method should not stomp match vars' );
-is( $foo->bar($1), 'foo', '(again)' );
-is( $foo->bazmarkhianish($1), 'foo', 'for any method call' );
+is( $foo->bazmarkhianish($1), 'foo', 'autoloaded method should not stomp match vars' );
is( $foo->bazmarkhianish($1), 'foo', '(again)' );
# Used to retry long subnames with shorter filenames on any old