/usr/lib/perl5/Tk/Pretty.pm is in perl-tk 1:804.031-1build1.
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 | # Copyright (c) 1995-2003 Nick Ing-Simmons. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
package Tk::Pretty;
require Exporter;
use vars qw($VERSION @EXPORT);
$VERSION = '4.006'; # $Id: //depot/Tkutf8/Tk/Pretty.pm#6 $
use base qw(Exporter);
@EXPORT = qw(Pretty PrintArgs);
sub pretty_list
{
join(',',map(&Pretty($_),@_));
}
sub Pretty
{
return pretty_list(@_) if (@_ > 1);
my $obj = shift;
return 'undef' unless defined($obj);
my $type = "$obj";
return $type if ($type =~ /=HASH/ && exists($obj->{"_Tcl_CmdInfo_\0"}));
my $result = '';
if (ref $obj)
{
my $class;
if ($type =~ /^([^=]+)=(.*)$/)
{
$class = $1;
$type = $2;
$result .= 'bless(';
}
if ($type =~ /^ARRAY/)
{
$result .= '[';
$result .= pretty_list(@$obj);
$result .= ']';
}
elsif ($type =~ /^HASH/)
{
$result .= '{';
if (%$obj)
{
my ($key, $value);
while (($key,$value) = each %$obj)
{
$result .= $key . '=>' . Pretty($value) . ',';
}
chop($result);
}
$result .= '}';
}
elsif ($type =~ /^REF/)
{
$result .= "\\" . Pretty($$obj);
}
elsif ($type =~ /^SCALAR/)
{
$result .= Pretty($$obj);
}
else
{
$result .= $type;
}
$result .= ",$class)" if (defined $class);
}
else
{
if ($obj =~ /^-?[0-9]+(.[0-9]*(e[+-][0-9]+)?)?$/ ||
$obj =~ /^[A-Z_][A-Za-z_0-9]*$/ ||
$obj =~ /^[a-z_][A-Za-z_0-9]*[A-Z_][A-Za-z_0-9]*$/
)
{
$result .= $obj;
}
else
{
$result .= "'" . $obj . "'";
}
}
return $result;
}
sub PrintArgs
{
my $name = (caller(1))[3];
print "$name(",Pretty(@_),")\n";
}
1;
|