| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Str::Iter; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
426715
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
86
|
|
|
4
|
2
|
|
|
2
|
|
20
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
146
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
31
|
use Exporter qw(import); |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
488
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
9
|
|
|
|
|
|
|
our $DATE = '2024-11-10'; # DATE |
|
10
|
|
|
|
|
|
|
our $DIST = 'Str-Iter'; # DIST |
|
11
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw(str_iter); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub str_iter { |
|
16
|
2
|
|
|
2
|
1
|
489737
|
my ($str, $n) = @_; |
|
17
|
2
|
100
|
|
|
|
10
|
$n = 1 unless defined $n; |
|
18
|
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
4
|
my $pos = 0; |
|
20
|
|
|
|
|
|
|
sub { |
|
21
|
12
|
100
|
|
12
|
|
58
|
if ($pos < length($str)) { |
|
22
|
10
|
|
|
|
|
21
|
my $substr = substr($str, $pos, $n); |
|
23
|
10
|
|
|
|
|
14
|
$pos += $n; |
|
24
|
10
|
|
|
|
|
29
|
return $substr; |
|
25
|
|
|
|
|
|
|
} else { |
|
26
|
2
|
|
|
|
|
7
|
return undef; ## no critic: Subroutines::ProhibitExplicitReturnUndef |
|
27
|
|
|
|
|
|
|
} |
|
28
|
2
|
|
|
|
|
16
|
}; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
|
32
|
|
|
|
|
|
|
# ABSTRACT: Generate a coderef iterator to iterate a string one (or more) character(s) at a time |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__END__ |