| 1 | #line 1 |
| 2 | # Scalar::Util::PP.pm |
| 3 | # |
| 4 | # Copyright (c) 1997-2009 Graham Barr <[email protected]>. All rights reserved. |
| 5 | # This program is free software; you can redistribute it and/or |
| 6 | # modify it under the same terms as Perl itself. |
| 7 | # |
| 8 | # This module is normally only loaded if the XS module is not available |
| 9 | |
| 10 | package Scalar::Util::PPscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/; |
| 11 | |
| 12 | use strictscip-perl cpan RDF-KML-Exporter 0.003 strict/; |
| 13 | use warningsscip-perl cpan RDF-KML-Exporter 0.003 warnings/; |
| 14 | use varsscip-perl cpan RDF-KML-Exporter 0.003 vars/ qw(@ISA @EXPORT $VERSION $recurse); |
| 15 | requirescip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/require(). Exporter; |
| 16 | use Bscip-perl cpan RDF-KML-Exporter 0.003 B/ qw(svref_2object); |
| 17 | |
| 18 | @ISAscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@ISA`. = qw(Exporter); |
| 19 | @EXPORTscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@EXPORT`. = qw(blessed reftype tainted readonly refaddr looks_like_number); |
| 20 | $VERSIONscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/$VERSION. = "1.23"; |
| 21 | $VERSIONscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/$VERSION. = eval $VERSIONscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/$VERSION.; |
| 22 | |
| 23 | sub blessedscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/blessed(). ($) { |
| 24 | return undef unless lengthscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/length().(refscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/ref().($_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@_`.[0])); |
| 25 | my $b = svref_2objectscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/svref_2object().($_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@_`.[0]); |
| 26 | return undef unless $b->isascip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/isa().('B::PVMG'); |
| 27 | my $s = $b->SvSTASHscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/SvSTASH().; |
| 28 | return $s->isascip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/isa().('B::HV') ? $s->NAMEscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/NAME(). : undef; |
| 29 | } |
| 30 | |
| 31 | sub refaddrscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/refaddr().($) { |
| 32 | return undef unless lengthscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/length().(refscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/ref().($_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@_`.[0])); |
| 33 | |
| 34 | my $addr; |
| 35 | if(definedscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/defined().(my $pkg = blessedscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/blessed().($_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@_`.[0]))) { |
| 36 | $addr .= blessscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/bless(). $_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@_`.[0], 'Scalar::Util::Fake'; |
| 37 | blessscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/bless(). $_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@_`.[0], $pkg; |
| 38 | } |
| 39 | else { |
| 40 | $addr .= $_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@_`.[0] |
| 41 | } |
| 42 | |
| 43 | $addr =~ /0x(\w+)/; |
| 44 | local $^Wscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`$^W`.; |
| 45 | no warnings 'portable'; |
| 46 | hexscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/hex().($1scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/$1.); |
| 47 | } |
| 48 | |
| 49 | { |
| 50 | my %tmap = qw( |
| 51 | B::NULL SCALAR |
| 52 | |
| 53 | B::HV HASH |
| 54 | B::AV ARRAY |
| 55 | B::CV CODE |
| 56 | B::IO IO |
| 57 | B::GV GLOB |
| 58 | B::REGEXP REGEXP |
| 59 | ); |
| 60 | |
| 61 | sub reftypescip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/reftype(). ($) { |
| 62 | my $r = shiftscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/shift().; |
| 63 | |
| 64 | return undef unless lengthscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/length().(refscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/ref().($r)); |
| 65 | |
| 66 | my $t = refscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/ref().(svref_2objectscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/svref_2object().($r)); |
| 67 | |
| 68 | return |
| 69 | existsscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/exists(). $tmap{$t} ? $tmap{$t} |
| 70 | : lengthscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/length().(refscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/ref().($$r)) ? 'REF' |
| 71 | : 'SCALAR'; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | sub taintedscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/tainted(). { |
| 76 | local($@scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`$@`., $SIGscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`%SIG`.{__DIE__}, $SIGscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`%SIG`.{__WARN__}); |
| 77 | local $^Wscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`$^W`. = 0; |
| 78 | no warnings; |
| 79 | eval { killscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/kill(). 0 * $_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@_`.[0] }; |
| 80 | $@scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`$@`. =~ /^Insecure/; |
| 81 | } |
| 82 | |
| 83 | sub readonlyscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/readonly(). { |
| 84 | return 0 if tiedscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/tied().($_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@_`.[0]) || (refscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/ref().(\($_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@_`.[0])) ne "SCALAR"); |
| 85 | |
| 86 | local($@scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`$@`., $SIGscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`%SIG`.{__DIE__}, $SIGscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`%SIG`.{__WARN__}); |
| 87 | my $tmp = $_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@_`.[0]; |
| 88 | |
| 89 | !eval { $_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`@_`.[0] = $tmp; 1 }; |
| 90 | } |
| 91 | |
| 92 | sub looks_like_numberscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/looks_like_number(). { |
| 93 | local $_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/$_. = shiftscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/shift().; |
| 94 | |
| 95 | # checks from perlfaq4 |
| 96 | return 0 if !definedscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/defined().($_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/$_.); |
| 97 | if (refscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/ref().($_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/$_.)) { |
| 98 | requirescip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/require(). overload; |
| 99 | return overload::Overloadedscip-perl cpan RDF-KML-Exporter 0.003 overload/Overloaded().($_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/$_.) ? definedscip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/defined().(0 + $_scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/$_.) : 0; |
| 100 | } |
| 101 | return 1 if (/^[+-]?[0-9]+$/); # is a +/- integer |
| 102 | return 1 if (/^([+-]?)(?=[0-9]|\.[0-9])[0-9]*(\.[0-9]*)?([Ee]([+-]?[0-9]+))?$/); # a C float |
| 103 | return 1 if ($]scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`$]`. >= 5.008 and /^(Inf(inity)?|NaN)$/i) or ($]scip-perl cpan RDF-KML-Exporter 0.003 Scalar/Util/PP/`$]`. >= 5.006001 and /^Inf$/i); |
| 104 | |
| 105 | 0; |
| 106 | } |
| 107 | |
| 108 | |
| 109 | 1; |