12 *UNIVERSAL::a_sub_not_likely_to_be_here = sub {
15 # deviation from Scalar::Util
16 # XS returns undef, PP returns GLOB.
17 # let's make that more consistent by having PP return
18 # undef if it's a GLOB. :/
20 # \*STDOUT would be allowed as an object in PP blessed
22 return $ref eq 'GLOB' ? undef : $ref;
27 local($@, $SIG{__DIE__}, $SIG{__WARN__});
29 ? eval { $_[0]->a_sub_not_likely_to_be_here }
33 'looks_like_number' => sub {
36 # checks from perlfaq4
37 return 0 if !defined($_) or ref($_);
38 return 1 if (/^[+-]?\d+$/); # is a +/- integer
39 return 1 if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/); # a C float
40 return 1 if ($] >= 5.008 and /^(Inf(inity)?|NaN)$/i) or ($] >= 5.006001 and /^Inf$/i);
45 local($@, $SIG{__DIE__}, $SIG{__WARN__});
49 length($t = ref($r)) or return undef;
51 # This eval will fail if the reference is not blessed
52 eval { $r->a_sub_not_likely_to_be_here; 1 }
55 # we have a GLOB or an IO. Stringify a GLOB gives it's name
57 $q =~ /^\*/ ? "GLOB" : "IO";
60 # OK, if we don't have a GLOB what parts of
61 # a glob will it populate.
62 # NOTE: A glob always has a SCALAR
64 defined *glob{ARRAY} && "ARRAY"
65 or defined *glob{HASH} && "HASH"
66 or defined *glob{CODE} && "CODE"
67 or length(ref(${$r})) ? "REF" : "SCALAR";
74 my $rt = reftype($fh) || '';
76 return defined(fileno($fh)) ? $fh : undef
79 if (reftype(\$fh) eq 'GLOB') { # handle openhandle(*DATA)
82 elsif ($rt ne 'GLOB') {
86 (tied(*$fh) or defined(fileno($fh)))
92 loaded => \&mro::get_linear_isa,
94 # this recurses so it isn't pretty
99 my $classname = shift;
101 my @lin = ($classname);
103 foreach my $parent (@{"$classname\::ISA"}) {
104 my $plin = $code->($parent);
106 next if exists $stored{$_};
118 our @EXPORT_OK = map { keys %$_ } values %dependencies;
120 for my $module_name (keys %dependencies) {
121 (my $file = "$module_name.pm") =~ s{::}{/}g;
124 local $SIG{__DIE__} = 'DEFAULT';
125 eval "require '$file'; 1";
128 for my $method_name (keys %{ $dependencies{ $module_name } }) {
129 my $producer = $dependencies{$module_name}{$method_name};
132 if (ref($producer) eq 'HASH') {
133 $implementation = $loaded
134 ? $producer->{loaded}
135 : $producer->{not_loaded};
138 $implementation = $loaded
139 ? $module_name->can($method_name)
144 *{ __PACKAGE__ . '::' . $method_name } = $implementation;
148 push @EXPORT_OK, qw(weaken);
150 require Scalar::Util;
151 goto \&Scalar::Util::weaken;