/usr/share/perl5/Tangram/Util.pm is in libtangram-perl 2.12-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 | package Tangram::Util;
# this space is for useful functions for tangram internals
our @EXPORT_OK = qw(pretty d);
use base qw(Exporter);
sub pretty {
my $thingy = shift;
if (defined($thingy)) {
return "`$thingy'";
} else {
return "undef";
}
}
use Scalar::Util qw(blessed reftype refaddr);
use Set::Object qw(is_int is_string is_double);
use Data::Dumper qw(Dumper);
# a compact, non-intrusive, non-recursive dumper. Similar to
# Class::Tangram::quickdump.
sub d {
return join "\n", map { d($_) } @_ if @_ > 1;
my @r;
if ( my $tie = tied $_[0] ) {
push @r, "(tied to ", $tie, ")";
}
elsif ( ref $_[0] ) {
push @r, ref($_[0]), "@", sprintf("0x%.8x", refaddr($_[0])),
(blessed($_[0]) ? (" (", reftype($_[0]), ")") : ()),
"\n";
if ( reftype $_[0] eq "HASH" ) {
for my $k (sort keys %{ $_[0] }) {
eval {
push @r, " ",$k," => ",
( tied $_[0]{$k}
|| ( ref $_[0]{$k}
? $_[0]{$k}
: ( defined ($_[0]{$k})
? "'".$_[0]{$k}."'"
: "undef" )
)
), "\n";
};
if ($@) {
push @r, " ", $k, " => Error('", $@, "')\n";
}
}
}
} else {
push @r, "(scalar, ",
join (",",
( is_int($_[0]) ? ("I=".(0+$_[0])) : () ),
( is_double($_[0]) ? ("N=".(0+$_[0])) : () ),
( is_string($_[0]) ? (do {
local($Data::Dumper::Terse)=1;
my $string = Dumper($_[0]);
chomp($string);
"P=$string";
}) : () ),
), ")";
}
return join "", @r;
}
1;
|