line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Text::Same::Range |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 DESCRIPTION |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
A class representing a range of integers |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $range = new Text::Same::Range($start, $end); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 METHODS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
See below. Methods private to this module are prefixed by an |
16
|
|
|
|
|
|
|
underscore. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
package Text::Same::Range; |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
3
|
|
22
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
92
|
|
23
|
3
|
|
|
3
|
|
19
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
113
|
|
24
|
3
|
|
|
3
|
|
17
|
use Carp; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1131
|
|
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
3
|
|
19
|
use vars qw($VERSION); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
1463
|
|
27
|
|
|
|
|
|
|
$VERSION = '0.07'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 new |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Title : new |
32
|
|
|
|
|
|
|
Usage : $range = new Text::Same::Range($start, $end) |
33
|
|
|
|
|
|
|
Function: Creates a new Range object with the given start and end |
34
|
|
|
|
|
|
|
Returns : A Text::Same::Range object |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new |
39
|
|
|
|
|
|
|
{ |
40
|
45
|
|
|
45
|
1
|
57
|
my $self = shift; |
41
|
45
|
|
33
|
|
|
172
|
my $class = ref($self) || $self; |
42
|
|
|
|
|
|
|
|
43
|
45
|
50
|
|
|
|
109
|
if (scalar(@_) != 2) { |
44
|
0
|
|
|
|
|
0
|
die "Range constructor needs 2 arguments\n"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
45
|
50
|
33
|
|
|
173
|
if (!defined $_[0] || !defined $_[1]) { |
48
|
0
|
|
|
|
|
0
|
croak "undefined value passed to Range->new\n"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
45
|
|
|
|
|
237
|
return bless [@_], $class; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 start |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Title : start |
57
|
|
|
|
|
|
|
Usage : $start = $range->start |
58
|
|
|
|
|
|
|
Function: Returns the start position that was passed to new() |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub start |
63
|
|
|
|
|
|
|
{ |
64
|
30
|
|
|
30
|
1
|
32
|
my $self = shift; |
65
|
30
|
|
|
|
|
89
|
return $self->[0]; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 end |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Title : end |
71
|
|
|
|
|
|
|
Usage : $end = $range->end |
72
|
|
|
|
|
|
|
Function: Returns the end position that was passed to new() |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub end |
77
|
|
|
|
|
|
|
{ |
78
|
30
|
|
|
30
|
1
|
39
|
my $self = shift; |
79
|
30
|
|
|
|
|
65
|
return $self->[1]; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 as_string |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Title : as_string |
85
|
|
|
|
|
|
|
Usage : my $str = $range->as_string |
86
|
|
|
|
|
|
|
Function: return a string representation of this Range |
87
|
|
|
|
|
|
|
Args : none |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub as_string |
92
|
|
|
|
|
|
|
{ |
93
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
94
|
0
|
|
|
|
|
|
return $self->[0] . ".." . $self->[1]; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHOR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Kim Rutherford |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Copyright 2005,2006 Kim Rutherford. All rights reserved. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
106
|
|
|
|
|
|
|
under the same terms as Perl itself. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 DISCLAIMER |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This module is provided "as is" without warranty of any kind. It |
111
|
|
|
|
|
|
|
may redistributed under the same conditions as Perl itself. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |