in reply to restore overridden XS methods
It seems that saving and restoring the glob doesn't work, but saving and restoring the CODE entry in the glob works for me:
perl -MTime::HiRes -le "my $x=*Time::HiRes::gettimeofday{CODE};*Time:: +HiRes::gettimeofday = sub(){42};print Time::HiRes::gettimeofday; *Tim +e::HiRes::gettimeofday = $x;print Time::HiRes::gettimeofday"
or, reformatted and untested:
use strict; use Time::HiRes; my $x=*Time::HiRes::gettimeofday{CODE}; *Time::HiRes::gettimeofday = sub(){42}; print "Modified: ", Time::HiRes::gettimeofday,"\n"; *Time::HiRes::gettimeofday = $x; print "Restored: ", Time::HiRes::gettimeofday
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: restore overridden XS methods
by bart (Canon) on Mar 01, 2007 at 12:04 UTC | |
by BrowserUk (Patriarch) on Mar 01, 2007 at 13:11 UTC | |
by bart (Canon) on Mar 01, 2007 at 13:26 UTC | |
by BrowserUk (Patriarch) on Mar 01, 2007 at 13:35 UTC | |
by bart (Canon) on Mar 02, 2007 at 01:11 UTC | |
|
Re^2: restore overridden XS methods
by dk (Chaplain) on Mar 01, 2007 at 10:38 UTC |