b374k
m1n1 1.01
Apache/2.2.15 (CentOS)
Linux obd60-6c49958d75-2q7cw 5.4.0-174-generic #193-Ubuntu SMP Thu Mar 7 14:29:28 UTC 2024 x86_64
uid=48(apache) gid=48(apache) groups=48(apache)
server ip : 172.67.192.52 | your ip : 10.244.126.0
safemode OFF
 >  / usr / lib64 / perl5 / Scalar / Util /
Filename/usr/lib64/perl5/Scalar/Util/PP.pm
Size2.18 kb
Permissionrw-r--r--
Ownerapache
Create time23-Dec-2025 17:41
Last modified22-Mar-2017 16:32
Last accessed22-Apr-2026 06:20
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
# Scalar::Util::PP.pm
#
# Copyright (c) 1997-2009 Graham Barr <[email protected]>. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
# This module is normally only loaded if the XS module is not available

package Scalar::Util::PP;

use strict;
use warnings;
use vars qw(@ISA @EXPORT $VERSION $recurse);
require Exporter;
use B qw(svref_2object);

@ISA = qw(Exporter);
@EXPORT = qw(blessed reftype tainted readonly refaddr looks_like_number);
$VERSION = "1.21";
$VERSION = eval $VERSION;

sub blessed ($) {
return undef unless length(ref($_[0]));
my $b = svref_2object($_[0]);
return undef unless $b->isa('B::PVMG');
my $s = $b->SvSTASH;
return $s->isa('B::HV') ? $s->NAME : undef;
}

sub refaddr($) {
return undef unless length(ref($_[0]));

my $addr;
if(defined(my $pkg = blessed($_[0]))) {
$addr .= bless $_[0], 'Scalar::Util::Fake';
bless $_[0], $pkg;
}
else {
$addr .= $_[0]
}

$addr =~ /0x(\w+)/;
local $^W;
hex($1);
}

{
my %tmap = qw(
B::HV HASH
B::AV ARRAY
B::CV CODE
B::IO IO
B::NULL SCALAR
B::NV SCALAR
B::PV SCALAR
B::GV GLOB
B::RV REF
B::REGEXP REGEXP
);

sub reftype ($) {
my $r = shift;

return undef unless length(ref($r));

my $t = ref(svref_2object($r));

return
exists $tmap{$t} ? $tmap{$t}
: length(ref($$r)) ? 'REF'
: 'SCALAR';
}
}

sub tainted {
local($@, $SIG{__DIE__}, $SIG{__WARN__});
local $^W = 0;
no warnings;
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 };
}

sub looks_like_number {
local $_ = shift;

# checks from perlfaq4
return 0 if !defined($_);
if (ref($_)) {
require overload;
return overload::Overloaded($_) ? defined(0 + $_) : 0;
}
return 1 if (/^[+-]?\d+$/); # is a +/- integer
return 1 if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/); # a C float
return 1 if ($] >= 5.008 and /^(Inf(inity)?|NaN)$/i) or ($] >= 5.006001 and /^Inf$/i);

0;
}


1;