Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Comment on

I've been asked recently how to tell which perl module overrides a function. Here's an exapmle I managed to write. It's incomplete and most certainly buggy, but I don't think the task in question is worth a full-blown CPAN module anyway.
#!/usr/bin/perl -w

use strict;

use Guard;
use Carp;
  my $guard = guard { Carp::cluck "Function replaced!" };
  my $code = \&time;
  *time = sub { return $code->(@_); undef $guard; };

BEGIN { print time(), "\n"; };

use Time::HiRes qw(time);

print time, "\n";
I welcome critique on this one.

In reply to Find out who redefined a subroutine by Dallaylaen

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (7)
    As of 2014-12-27 05:15 GMT
    Find Nodes?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?

      Results (176 votes), past polls