diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-04-26 18:43:51 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-04-26 18:43:51 +0000 |
commit | 07766739ad671051f274806a83c05be36e7ca89a (patch) | |
tree | 17b8d5a4d43e11e6e582d71ed140ef7529440a0a /ext/List/Util | |
parent | 4f9457819ee16b3f645ab5dab5ddc5ddbc89ebcf (diff) | |
download | perl-07766739ad671051f274806a83c05be36e7ca89a.tar.gz |
The Time::Piece conspiracy unmasked!!!
From: Mike Guy <mjtg@cam.ac.uk>
Date: Thu, 26 Apr 2001 19:02:50 +0100
Message-Id: <E14sq6M-0002g9-00@libra.cus.cam.ac.uk>
Subject: [PATCH] that's enough UNIVERSAL stuff for one day ...
From: Mike Guy <mjtg@cam.ac.uk>
Date: Thu, 26 Apr 2001 19:08:21 +0100
Message-Id: <E14sqBh-0002mI-00@libra.cus.cam.ac.uk>
Subject: Re: [PATCH] that's enough UNIVERSAL stuff for one day ...
From: Graham Barr <gbarr@pobox.com>
Date: Thu, 26 Apr 2001 19:12:03 +0100
Message-ID: <20010426191203.A70835@pobox.com>
Eradicate UNIVERSAL (Mike) and remove the fallback Perl code (Graham)
p4raw-id: //depot/perl@9859
Diffstat (limited to 'ext/List/Util')
-rw-r--r-- | ext/List/Util/lib/List/Util.pm | 45 | ||||
-rw-r--r-- | ext/List/Util/lib/Scalar/Util.pm | 63 |
2 files changed, 0 insertions, 108 deletions
diff --git a/ext/List/Util/lib/List/Util.pm b/ext/List/Util/lib/List/Util.pm index 053134d91e..641ca97a21 100644 --- a/ext/List/Util/lib/List/Util.pm +++ b/ext/List/Util/lib/List/Util.pm @@ -19,51 +19,6 @@ eval { 1 }; -eval <<'ESQ' unless defined &reduce; - -# This code is only compiled if the XS did not load - -use vars qw($a $b); - -sub reduce (&@) { - my $code = shift; - - return shift unless @_ > 1; - - my $caller = caller; - local(*{$caller."::a"}) = \my $a; - local(*{$caller."::b"}) = \my $b; - - $a = shift; - foreach (@_) { - $b = $_; - $a = &{$code}(); - } - - $a; -} - -sub sum (@) { reduce { $a + $b } @_ } - -sub min (@) { reduce { $a < $b ? $a : $b } @_ } - -sub max (@) { reduce { $a > $b ? $a : $b } @_ } - -sub minstr (@) { reduce { $a lt $b ? $a : $b } @_ } - -sub maxstr (@) { reduce { $a gt $b ? $a : $b } @_ } - -sub first (&@) { - my $code = shift; - - foreach (@_) { - return $_ if &{$code}(); - } - - undef; -} -ESQ - 1; __END__ diff --git a/ext/List/Util/lib/Scalar/Util.pm b/ext/List/Util/lib/Scalar/Util.pm index ee65667358..2b81d8e903 100644 --- a/ext/List/Util/lib/Scalar/Util.pm +++ b/ext/List/Util/lib/Scalar/Util.pm @@ -26,69 +26,6 @@ sub export_fail { @_; } -eval <<'ESQ' unless defined &dualvar; - -push @EXPORT_FAIL, qw(weaken isweak dualvar); - -# The code beyond here is only used if the XS is not installed - -# Hope nobody defines a sub by this name -sub UNIVERSAL::a_sub_not_likely_to_be_here { ref($_[0]) } - -sub blessed ($) { - local($@, $SIG{__DIE__}, $SIG{__WARN__}); - length(ref($_[0])) - ? eval { $_[0]->a_sub_not_likely_to_be_here } - : undef -} - -sub reftype ($) { - local($@, $SIG{__DIE__}, $SIG{__WARN__}); - my $r = shift; - my $t; - - length($t = ref($r)) or return undef; - - # This eval will fail if the reference is not blessed - eval { $r->a_sub_not_likely_to_be_here; 1 } - ? do { - $t = eval { - # we have a GLOB or an IO. Stringify a GLOB gives it's name - my $q = *$r; - $q =~ /^\*/ ? "GLOB" : "IO"; - } - or do { - # OK, if we don't have a GLOB what parts of - # a glob will it populate. - # NOTE: A glob always has a SCALAR - local *glob = $r; - defined *glob{ARRAY} && "ARRAY" - or defined *glob{HASH} && "HASH" - or defined *glob{CODE} && "CODE" - or length(ref(${$r})) ? "REF" : "SCALAR"; - } - } - : $t -} - -sub tainted { - local($@, $SIG{__DIE__}, $SIG{__WARN__}); - local $^W = 0; - eval { kill 0 * $_[0] }; - $@ =~ /^Insecure/; -} - -sub readonly { - return 0 if tied($_[0]) || (ref(\($_[0])) ne "SCALAR"); - - local($@, $SIG{__DIE__}, $SIG{__WARN__}); - my $tmp = $_[0]; - - !eval { $_[0] = $tmp; 1 }; -} - -ESQ - 1; __END__ |