/usr/share/perl5/Ref/Util/PP.pm is in libref-util-perl 0.203-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | package Ref::Util::PP;
$Ref::Util::PP::VERSION = '0.203';
# ABSTRACT: pure-Perl version of Ref::Util
use strict;
use warnings;
use Carp ();
use Scalar::Util ();
use Exporter 5.57 'import';
use constant _FORMAT_REFS_WORK => ("$]" >= 5.007);
use constant _RX_NEEDS_MAGIC => (Scalar::Util::reftype(qr/^/) ne 'REGEXP');
our %EXPORT_TAGS = ( 'all' => [qw<
is_ref
is_scalarref
is_arrayref
is_hashref
is_coderef
is_regexpref
is_globref
is_formatref
is_ioref
is_refref
is_plain_ref
is_plain_scalarref
is_plain_arrayref
is_plain_hashref
is_plain_coderef
is_plain_globref
is_plain_formatref
is_plain_refref
is_blessed_ref
is_blessed_scalarref
is_blessed_arrayref
is_blessed_hashref
is_blessed_coderef
is_blessed_globref
is_blessed_formatref
is_blessed_refref
>] );
our @EXPORT = ();
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
sub _using_custom_ops () { 0 }
if (_RX_NEEDS_MAGIC) {
require B;
*_is_regexp = sub {
no warnings 'uninitialized';
return 0 if ref($_[0]) eq '';
my $o = B::svref_2object($_[0]) or return 0;
return 0 if Scalar::Util::blessed($o) ne 'B::PVMG';
my $m = $o->MAGIC;
while ($m) {
return 1 if $m->TYPE eq 'r';
$m = $m->MOREMAGIC;
}
return 0;
};
}
# ----
# -- is_*
# ----
sub is_ref($) { length ref $_[0] }
sub is_scalarref($) {
no warnings 'uninitialized';
Carp::croak("Too many arguments for is_scalarref") if @_ > 1;
my $reftype = Scalar::Util::reftype( $_[0] );
( $reftype eq 'SCALAR' || $reftype eq 'VSTRING' )
&& (!_RX_NEEDS_MAGIC || !_is_regexp($_[0]));
}
sub is_arrayref($) {
no warnings 'uninitialized';
Carp::croak("Too many arguments for is_arrayref") if @_ > 1;
Scalar::Util::reftype( $_[0] ) eq 'ARRAY';
}
sub is_hashref($) {
no warnings 'uninitialized';
Carp::croak("Too many arguments for is_hashref") if @_ > 1;
Scalar::Util::reftype( $_[0] ) eq 'HASH';
}
sub is_coderef($) {
no warnings 'uninitialized';
Carp::croak("Too many arguments for is_coderef") if @_ > 1;
Scalar::Util::reftype( $_[0] ) eq 'CODE';
}
sub is_regexpref($) {
no warnings 'uninitialized';
Carp::croak("Too many arguments for is_regexpref") if @_ > 1;
_RX_NEEDS_MAGIC ? _is_regexp( $_[0] )
: re::is_regexp( $_[0] );
}
sub is_globref($) {
no warnings 'uninitialized';
Carp::croak("Too many arguments for is_globref") if @_ > 1;
Scalar::Util::reftype( $_[0] ) eq 'GLOB';
}
sub is_formatref($) {
_FORMAT_REFS_WORK
or
Carp::croak("is_formatref() isn't available on Perl 5.6.x and under");
no warnings 'uninitialized';
Carp::croak("Too many arguments for is_formatref") if @_ > 1;
Scalar::Util::reftype( $_[0] ) eq 'FORMAT';
}
sub is_ioref($) {
no warnings 'uninitialized';
Carp::croak("Too many arguments for is_ioref") if @_ > 1;
Scalar::Util::reftype( $_[0] ) eq 'IO';
}
sub is_refref($) {
no warnings 'uninitialized';
Carp::croak("Too many arguments for is_refref") if @_ > 1;
Scalar::Util::reftype( $_[0] ) eq 'REF';
}
# ----
# -- is_plain_*
# ----
sub is_plain_ref($) {
Carp::croak("Too many arguments for is_plain_ref") if @_ > 1;
ref $_[0] && !Scalar::Util::blessed( $_[0] );
}
sub is_plain_scalarref($) {
Carp::croak("Too many arguments for is_plain_scalarref") if @_ > 1;
!defined Scalar::Util::blessed( $_[0] )
&& ( ref( $_[0] ) eq 'SCALAR' || ref( $_[0] ) eq 'VSTRING' );
}
sub is_plain_arrayref($) {
Carp::croak("Too many arguments for is_plain_arrayref") if @_ > 1;
!defined Scalar::Util::blessed( $_[0] )
&& ref( $_[0] ) eq 'ARRAY';
}
sub is_plain_hashref($) {
Carp::croak("Too many arguments for is_plain_hashref") if @_ > 1;
!defined Scalar::Util::blessed( $_[0] )
&& ref( $_[0] ) eq 'HASH';
}
sub is_plain_coderef($) {
Carp::croak("Too many arguments for is_plain_coderef") if @_ > 1;
!defined Scalar::Util::blessed( $_[0] )
&& ref( $_[0] ) eq 'CODE';
}
sub is_plain_globref($) {
Carp::croak("Too many arguments for is_plain_globref") if @_ > 1;
!defined Scalar::Util::blessed( $_[0] )
&& ref( $_[0] ) eq 'GLOB';
}
sub is_plain_formatref($) {
_FORMAT_REFS_WORK
or
Carp::croak("is_plain_formatref() isn't available on Perl 5.6.x and under");
Carp::croak("Too many arguments for is_plain_formatref") if @_ > 1;
!defined Scalar::Util::blessed( $_[0] )
&& ref( $_[0] ) eq 'FORMAT';
}
sub is_plain_refref($) {
Carp::croak("Too many arguments for is_plain_refref") if @_ > 1;
!defined Scalar::Util::blessed( $_[0] )
&& ref( $_[0] ) eq 'REF';
}
# ----
# -- is_blessed_*
# ----
sub is_blessed_ref($) {
Carp::croak("Too many arguments for is_blessed_ref") if @_ > 1;
defined Scalar::Util::blessed( $_[0] );
}
sub is_blessed_scalarref($) {
Carp::croak("Too many arguments for is_blessed_scalarref") if @_ > 1;
my $reftype = Scalar::Util::reftype( $_[0] );
defined Scalar::Util::blessed( $_[0] )
&& ($reftype eq 'SCALAR' || $reftype eq 'VSTRING')
&& (!_RX_NEEDS_MAGIC || !_is_regexp( $_[0] ));
}
sub is_blessed_arrayref($) {
Carp::croak("Too many arguments for is_blessed_arrayref") if @_ > 1;
defined Scalar::Util::blessed( $_[0] )
&& Scalar::Util::reftype( $_[0] ) eq 'ARRAY';
}
sub is_blessed_hashref($) {
Carp::croak("Too many arguments for is_blessed_hashref") if @_ > 1;
defined Scalar::Util::blessed( $_[0] )
&& Scalar::Util::reftype( $_[0] ) eq 'HASH';
}
sub is_blessed_coderef($) {
Carp::croak("Too many arguments for is_blessed_coderef") if @_ > 1;
defined Scalar::Util::blessed( $_[0] )
&& Scalar::Util::reftype( $_[0] ) eq 'CODE';
}
sub is_blessed_globref($) {
Carp::croak("Too many arguments for is_blessed_globref") if @_ > 1;
defined Scalar::Util::blessed( $_[0] )
&& Scalar::Util::reftype( $_[0] ) eq 'GLOB';
}
sub is_blessed_formatref($) {
_FORMAT_REFS_WORK
or
Carp::croak("is_blessed_formatref() isn't available on Perl 5.6.x and under");
Carp::croak("Too many arguments for is_blessed_formatref") if @_ > 1;
defined Scalar::Util::blessed( $_[0] )
&& Scalar::Util::reftype( $_[0] ) eq 'FORMAT';
}
sub is_blessed_refref($) {
Carp::croak("Too many arguments for is_blessed_refref") if @_ > 1;
defined Scalar::Util::blessed( $_[0] )
&& Scalar::Util::reftype( $_[0] ) eq 'REF';
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Ref::Util::PP - pure-Perl version of Ref::Util
=head1 VERSION
version 0.203
=head1 SYNOPSIS
use Ref::Util;
=head1 DESCRIPTION
This module provides a pure-Perl implementation of the functions in
L<Ref::Util>.
Ref::Util:PP will be used automatically if Ref::Util is installed on a
system with no C compiler, but you can force its usage by setting either
C<$Ref::Util::IMPLEMENTATION> or the C<PERL_REF_UTIL_IMPLEMENTATION>
environment variable to C<PP>.
=head1 AUTHORS
=over 4
=item *
Sawyer X <xsawyerx@cpan.org>
=item *
Aaron Crane <arc@cpan.org>
=item *
Vikenty Fesunov <vyf@cpan.org>
=item *
Gonzalo Diethelm <gonzus@cpan.org>
=item *
Karen Etheridge <ether@cpan.org>
=back
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2017 by Sawyer X.
This is free software, licensed under:
The MIT (X11) License
=cut
|