This file is indexed.

/usr/share/doc/libtext-asciitable-perl/examples/ansi-example.pl is in libtext-asciitable-perl 0.22-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
#!/usr/bin/perl
# Ugly example-usage of Text::ASCIITable with ANSI support
#
# Usage: ./ansi-example.pl <0|1>
#
# Parameter turns "drawRowLine" on and off.

=head1 NAME

ansi-example.pl - An example of how to use ANSI colors with Text::ASCIITable

=head1 SHORT DESCRIPTION

This is a ugly hack to show you how nice a ansi-shaped and -colored table can
look like. It doesn't have to be an ugly hack, but this example is. If anyone
could bother to write a prettier one, code-wise, I would be really glad if you
sent it to me, so I could replace it with this.

=head1 SYNOPSIS

  ./ansi-example.pl
  echo Wow!

=head1 REQUIRES

Text::ASCIITable

=head1 AUTHOR

Håkon Nessjøen, <lunatic@cpan.org> would like to remain anonymous.

=cut

use Text::ASCIITable;

$tt = Text::ASCIITable->new;
$tt->setOptions({allowANSI => 1, drawRowLine => int($ARGV[0]) });
$tt->setCols('eth0','eth1','total');
$tt->alignCol({ 'eth0' => 'center', 'eth1' => 'center' });
$tt->addRow(gc('a'),gc('opqrs'));
$tt->addRow(gc("a\na"),gc("a\naa"));

$t = Text::ASCIITable->new({allowANSI => 1, drawRowLine => int($ARGV[0]) });
$t->setCols( [ ye('One'), ye('Two'), ye('Three') ] );
$t->alignCol({ ye('One') => 'center', ye('Two') => 'right' });
$t->setColWidth(ye('Three'),81);

$t->addRow(g('green'),c('cyan'),ma('magenta'));
$t->addRow(c('ansi'), $tt->draw( ["\e(0\e[31ml\e[m\e(B","\e(0\e[31mk\e[m\e(B","\e(0\e[31mq\e[m\e(B","\e(0\e[31mw\e[m\e(B"],
                     ["\e(0\e[31mx\e[m\e(B","\e(0\e[31mx\e[m\e(B","\e(0\e[31mx\e[m\e(B"],
                     ["\e(0\e[31mt\e[m\e(B","\e(0\e[31mu\e[m\e(B","\e(0\e[31;1mq\e[m\e(B","\e(0\e[31;1mn\e[m\e(B"],
                     ["\e(0\e[31mx\e[m\e(B","\e(0\e[31mx\e[m\e(B","\e(0\e[31mx\e[m\e(B"],
                     ["\e(0\e[31mm\e[m\e(B","\e(0\e[31mj\e[m\e(B","\e(0\e[31mq\e[m\e(B","\e(0\e[31mv\e[m\e(B"],
                     ["\e(0\e[31mt\e[m\e(B","\e(0\e[31mu\e[m\e(B","\e(0\e[31mq\e[m\e(B","\e(0\e[31mn\e[m\e(B"]
                    ), $tt->draw()
);

# Draw table to screen
print $t->draw( ["\e(0\e[32ml\e[m\e(B","\e(0\e[32mk\e[m\e(B","\e(0\e[32mq\e[m\e(B","\e(0\e[32mw\e[m\e(B"],
                     ["\e(0\e[32mx\e[m\e(B","\e(0\e[32mx\e[m\e(B","\e(0\e[32mx\e[m\e(B"],
                     ["\e(0\e[32mt\e[m\e(B","\e(0\e[32mu\e[m\e(B","\e(0\e[32;1mq\e[m\e(B","\e(0\e[32;1mn\e[m\e(B"],
                     ["\e(0\e[32mx\e[m\e(B","\e(0\e[32mx\e[m\e(B","\e(0\e[32mx\e[m\e(B"],
                     ["\e(0\e[32mm\e[m\e(B","\e(0\e[32mj\e[m\e(B","\e(0\e[32mq\e[m\e(B","\e(0\e[32mv\e[m\e(B"],
                     ["\e(0\e[32mt\e[m\e(B","\e(0\e[32mu\e[m\e(B","\e(0\e[32mq\e[m\e(B","\e(0\e[32mn\e[m\e(B"]
                    );

# Subroutines
sub gc { # Write Graphical characters, correctly with newline
  my $out='';
  my @ary = split(/\n/,shift());
  for (0..$#ary) {
	  $out .= "\e(0".$ary[$_]."\e(B";
		$out .= "\n" if ($_ ne $#ary);
  }
	$out;
}

# Green
sub g {return "\e[32;1m".shift()."\e[m";}

# Yellow
sub ye {return "\e[33;1m".shift()."\e[m";}

# Cyan
sub c {return "\e[36;1m".shift()."\e[m";}

# Magenta
sub ma {return "\e[35;1m".shift()."\e[m";}