line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Petal::Utils::Substr; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
30
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
177
|
|
4
|
5
|
|
|
5
|
|
29
|
use warnings::register; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
584
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
27
|
use Carp; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
344
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
27
|
use base qw( Petal::Utils::Base ); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
393
|
|
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
27
|
use constant name => 'substr'; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
272
|
|
11
|
5
|
|
|
5
|
|
33
|
use constant aliases => qw(); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
1561
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = ((require Petal::Utils), $Petal::Utils::VERSION)[1]; |
14
|
|
|
|
|
|
|
our $REVISION = (split(/ /, ' $Revision: 1.2 $ '))[2]; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub process { |
17
|
5
|
|
|
5
|
0
|
38405
|
my $class = shift; |
18
|
5
|
|
|
|
|
8
|
my $hash = shift; |
19
|
5
|
|
33
|
|
|
16
|
my $args = shift || confess( "'create_href' expects 1 or 2 variables (got nothing)!" ); |
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
|
|
29
|
my @args = $class->split_args( $args ); |
22
|
5
|
|
33
|
|
|
17
|
my $text_key = $args[0] || confess( "1st arg to 'limit' should be a variable (got nothing)!" ); |
23
|
5
|
|
|
|
|
69
|
my $text = $hash->fetch($text_key); |
24
|
5
|
|
100
|
|
|
442
|
my $start = $args[1] || 0; |
25
|
5
|
|
66
|
|
|
18
|
my $len = $args[2] || length($text); |
26
|
5
|
|
100
|
|
|
17
|
my $ellipsis = $args[3] || 0; |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
|
|
12
|
my $new_text = substr($text, $start, $len); |
29
|
5
|
100
|
66
|
|
|
21
|
if ( $ellipsis && (length($new_text) >= ($len - $start)) ) { |
30
|
2
|
|
|
|
|
3
|
$new_text .= "..."; |
31
|
|
|
|
|
|
|
} |
32
|
5
|
|
|
|
|
26
|
return $new_text; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |