/usr/share/perl5/Devel/Confess/Source.pm is in libdevel-confess-perl 0.009004-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 | package Devel::Confess::Source;
use 5.006;
use strict;
use warnings FATAL => 'all';
sub import {
$^P |= "$]" >= 5.010 ? 0x400 : do {
*DB::DB = sub {}
unless defined &DB::DB;
0x02;
};
}
my $want_color = $^O ne 'MSWin32' ? 1 : eval {
require Win32::Console::ANSI;
Win32::Console::ANSI->import;
1;
};
sub source_trace {
my ($skip, $context, $evalonly) = @_;
$skip ||= 1;
$skip += $Carp::CarpLevel;
$context ||= 3;
my $i = $skip;
my @out;
while (my ($pack, $file, $line) = (caller($i++))[0..2]) {
next
if $Carp::Internal{$pack} || $Carp::CarpInternal{$pack};
next
if $evalonly && $file !~ /^\(eval \d+\)(?:\[|$)/;
my $lines = _get_content($file) || next;
my $start = $line - $context;
$start = 1 if $start < 1;
$start = $#$lines if $start > $#$lines;
my $end = $line + $context;
$end = $#$lines if $end > $#$lines;
my $context = "context for $file line $line:\n";
for my $read_line ($start..$end) {
my $code = $lines->[$read_line];
$code =~ s/\n\z//;
if ($want_color && $read_line == $line) {
$code = "\e[30;43m$code\e[m";
}
$context .= sprintf "%5s : %s\n", $read_line, $code;
}
push @out, $context;
}
return ''
if !@out;
return join(('=' x 75) . "\n",
'',
join(('-' x 75) . "\n", @out),
'',
);
}
sub _get_content {
my $file = shift;
no strict 'refs';
if (exists $::{'_<'.$file} && @{ '::_<'.$file }) {
return \@{ '::_<'.$file };
}
elsif ($file =~ /^\(eval \d+\)(?:\[.*\])?$/) {
return ["Can't get source of evals unless debugger available!"];
}
elsif (open my $fh, '<', $file) {
my @lines = ('', <$fh>);
return \@lines;
}
else {
return ["Source file not available!"];
}
}
1;
|