line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Karel::Util; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Karel::Util |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRITPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Helper functions for other packages. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 FUNCTIONS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=over 4 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=item m_to_n($i, $m, $n) |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Checks whether the integer C<$i> lies between C<$m> and C<$n> |
18
|
|
|
|
|
|
|
inclusive. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=item positive_int($i) |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Checks whether C<$i> is a positive integer, i.e. C. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=back |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
10
|
|
|
10
|
|
96258
|
use warnings; |
|
10
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
315
|
|
29
|
10
|
|
|
10
|
|
44
|
use strict; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
185
|
|
30
|
|
|
|
|
|
|
|
31
|
10
|
|
|
10
|
|
42
|
use Carp; |
|
10
|
|
|
|
|
23
|
|
|
10
|
|
|
|
|
572
|
|
32
|
10
|
|
|
10
|
|
521
|
use parent qw( Exporter ); |
|
10
|
|
|
|
|
366
|
|
|
10
|
|
|
|
|
111
|
|
33
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ positive_int m_to_n }; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub m_to_n { |
37
|
3870
|
|
|
3870
|
1
|
10326
|
my ($i, $m, $n) = @_; |
38
|
|
|
|
|
|
|
defined && /^[0-9]+$/ |
39
|
|
|
|
|
|
|
or croak +($_ // 'undef') . ' should be non negative integer' |
40
|
3870
|
|
100
|
|
|
44371
|
for $i, $m, $n; |
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
41
|
3866
|
100
|
100
|
|
|
19205
|
$m <= $i && $i <= $n or croak "$i not between $m and $n"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub positive_int { |
46
|
240
|
|
|
240
|
1
|
76459
|
my $i = shift; |
47
|
240
|
|
|
|
|
464
|
m_to_n($i, 1, $i) |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__PACKAGE__ |