line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Truncate;
|
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
8099
|
use 5.00400;
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
87
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings;
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
76
|
|
5
|
2
|
|
|
2
|
|
21
|
use strict;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
80
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
9
|
use Carp;
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
179
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter;
|
10
|
2
|
|
|
2
|
|
12
|
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK $DEFAULT_MARKER );
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
599
|
|
11
|
|
|
|
|
|
|
@ISA = qw( Exporter );
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
@EXPORT_OK = ( @EXPORT, qw( $DEFAULT_MARKER ) );
|
14
|
|
|
|
|
|
|
@EXPORT = qw(
|
15
|
|
|
|
|
|
|
truncstr
|
16
|
|
|
|
|
|
|
);
|
17
|
|
|
|
|
|
|
$VERSION = '1.06';
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$DEFAULT_MARKER = "...";
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub truncstr
|
22
|
|
|
|
|
|
|
{
|
23
|
637
|
|
|
637
|
1
|
374462
|
my $string = shift;
|
24
|
637
|
|
|
|
|
798
|
my $cutoff = shift;
|
25
|
637
|
|
|
|
|
769
|
my $marker = shift;
|
26
|
|
|
|
|
|
|
|
27
|
637
|
100
|
50
|
|
|
1639
|
$marker = ($DEFAULT_MARKER || ""), unless (defined($marker));
|
28
|
|
|
|
|
|
|
|
29
|
637
|
50
|
|
|
|
1318
|
croak "continued symbol is longer than the cutoff length",
|
30
|
|
|
|
|
|
|
if (length($marker) > $cutoff);
|
31
|
|
|
|
|
|
|
|
32
|
637
|
100
|
|
|
|
1219
|
if (length($string) > $cutoff) {
|
33
|
180
|
|
100
|
|
|
612
|
$string = (substr($string, 0, $cutoff-length($marker))||"") . $marker;
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
|
36
|
637
|
|
|
|
|
1616
|
return $string;
|
37
|
|
|
|
|
|
|
}
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1;
|
40
|
|
|
|
|
|
|
__END__
|