in reply to restore overridden XS methods

my $x = *Time::HiRes::gettimeofday; # ... # ... # ... *Time::HiRes::gettimeofday = sub { $x; };
worked for me and ought to be more class-independent and future-compatible.

Update: I should have said it worked for me when testing on a core module, rather than the one actually raised! :("

-M

Free your mind

Replies are listed 'Best First'.
Re^2: restore overridden XS methods
by almut (Canon) on Mar 01, 2007 at 14:13 UTC

    doesn't seem to work for me :)

    my $x = *Time::HiRes::gettimeofday; print "original: ", Time::HiRes::gettimeofday(), "\n"; # ... *Time::HiRes::gettimeofday = sub() { $x; }; # ^^ avoids "Prototype mismatch" print "restored: ", Time::HiRes::gettimeofday(), "\n";

    prints:

    original: 117275763140928 restored: *Time::HiRes::gettimeofday

    (i.e. after having been restored, the function prints the stringified representation of the glob $x)