tall_man has asked for the wisdom of the Perl Monks concerning the following question:
I tried creating my own override of the whole List::Util package, but the XS part was not portable to all systems.
Instead, to fill in the missing function, I created the following module:
package PatchPackages; use strict; use version; our $VERSION = qv/0.0.1/; sub import { require Scalar::Util; if (! Scalar::Util->can('refaddr')) { # Copied from more recent Scalar::Util code. # Makes up for this function being missing on some # of our 5.8.0 installations. *Scalar::Util::refaddr = sub ($) { my $pkg = ref($_[0]) or return undef; if (Scalar::Util::blessed($_[0])) { bless $_[0], 'Scalar::Util::Fake'; } else { $pkg = undef; } "$_[0]" =~ /0x(\w+)/; my $i = do { local $^W; hex $1 }; bless $_[0], $pkg if defined $pkg; $i; } } } 1;
This seems a little messy, but it works. Does anyone know of a cleaner way to do this?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Patching a Package (Scalar::Util)
by ikegami (Patriarch) on Apr 19, 2006 at 17:26 UTC | |
Re: Patching a Package (Scalar::Util)
by dragonchild (Archbishop) on Apr 19, 2006 at 16:44 UTC | |
by tall_man (Parson) on Apr 19, 2006 at 19:32 UTC | |
Re: Patching a Package (Scalar::Util)
by xdg (Monsignor) on Apr 19, 2006 at 18:20 UTC | |
Re: Patching a Package (Scalar::Util)
by ikegami (Patriarch) on Apr 19, 2006 at 17:37 UTC | |
Re: Patching a Package (Scalar::Util)
by demerphq (Chancellor) on Apr 19, 2006 at 22:36 UTC |