/usr/share/perl5/SHARYANTO/Data/OldUtil.pm is in libsharyanto-utils-perl 0.53-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 | package SHARYANTO::Data::OldUtil;
use 5.010;
use strict;
use warnings;
#use experimental 'smartmatch';
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(has_circular_ref);
our $VERSION = '0.53'; # VERSION
our %SPEC;
$SPEC{has_circular_ref} = {
v => 1.1,
summary => 'Check whether data item contains circular references',
description => <<'_',
Does not deal with weak references.
_
args_as => 'array',
args => {
data => {
schema => "any",
pos => 0,
req => 1,
},
},
result_naked => 1,
};
sub has_circular_ref {
my ($data) = @_;
my %refs;
my $check;
$check = sub {
my $x = shift;
my $r = ref($x);
return 0 if !$r;
return 1 if $refs{"$x"}++;
if ($r eq 'ARRAY') {
for (@$x) {
next unless ref($_);
return 1 if $check->($_);
}
} elsif ($r eq 'HASH') {
for (values %$x) {
next unless ref($_);
return 1 if $check->($_);
}
}
0;
};
$check->($data);
}
1;
# ABSTRACT: Data utilities
__END__
=pod
=encoding utf-8
=head1 NAME
SHARYANTO::Data::OldUtil - Data utilities
=head1 VERSION
version 0.53
=head1 SYNOPSIS
=head1 DESCRIPTION
=head1 FUNCTIONS
None are exported by default, but they are exportable.
None are exported by default, but they are exportable.
=head2 has_circular_ref(@args) -> any
Does not deal with weak references.
Arguments ('*' denotes required arguments):
=over 4
=item * B<data>* => I<any>
=back
Return value:
=head1 SEE ALSO
L<Data::Structure::Util> has the XS/C version of C<has_circular_ref> which is 3
times or more faster than this module's implementation which is pure Perl). Use
that instead.
This module is however much faster than L<Devel::Cycle>.
=head1 AUTHOR
Steven Haryanto <stevenharyanto@gmail.com>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|