/usr/share/perl5/Code/TidyAll/Util.pm is in libcode-tidyall-perl 0.32~dfsg-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 | package Code::TidyAll::Util;
use Cwd qw(realpath);
use Data::Dumper;
use File::Basename;
use File::Path;
use File::Spec::Functions qw(abs2rel rel2abs);
use File::Temp qw(tempdir);
use Guard;
use List::MoreUtils qw(uniq);
use Try::Tiny;
use strict;
use warnings;
use base qw(Exporter);
our $VERSION = '0.32';
our @EXPORT_OK
= qw(abs2rel basename can_load dirname dump_one_line mkpath pushd read_dir realpath rel2abs tempdir_simple trim uniq);
sub can_load {
# Load $class_name if possible. Return 1 if successful, 0 if it could not be
# found, and rethrow load error (other than not found).
#
my ($class_name) = @_;
my $result;
try {
eval "require $class_name"; ## no critic
die $@ if $@;
$result = 1;
}
catch {
if ( /Can\'t locate .* in \@INC/ && !/Compilation failed/ ) {
$result = 0;
}
else {
die $_;
}
};
return $result;
}
sub tempdir_simple {
my $template = shift || 'Code-TidyAll-XXXX';
return realpath( tempdir( $template, TMPDIR => 1, CLEANUP => 1 ) );
}
sub dump_one_line {
my ($value) = @_;
return Data::Dumper->new( [$value] )->Indent(0)->Sortkeys(1)->Quotekeys(0)->Terse(1)->Dump();
}
sub pushd {
my ($dir) = @_;
my $cwd = realpath();
chdir($dir);
return guard { chdir($cwd) };
}
sub trim {
my ($str) = @_;
for ($str) { s/^\s+//; s/\s+$// }
return $str;
}
sub read_dir {
my ($dir) = @_;
opendir( my $dirh, $dir ) or die "could not open $dir: $!";
my @dir_entries = grep { $_ ne "." && $_ ne ".." } readdir($dirh);
return @dir_entries;
}
1;
|