line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Purple::Sequence; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
319
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub increment_nid { |
7
|
1
|
|
|
1
|
1
|
3
|
my $old_nid = shift; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
|
|
51
|
my @oldValues = split('', $old_nid); |
10
|
1
|
|
|
|
|
3
|
my @newValues; |
11
|
1
|
|
|
|
|
2
|
my $carryBit = 1; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
|
|
4
|
foreach my $char (reverse(@oldValues)) { |
14
|
1
|
50
|
|
|
|
9
|
if ($carryBit) { |
15
|
1
|
|
|
|
|
2
|
my $newChar; |
16
|
1
|
|
|
|
|
4
|
($newChar, $carryBit) = _incChar($char); |
17
|
1
|
|
|
|
|
4
|
push(@newValues, $newChar); |
18
|
|
|
|
|
|
|
} else { |
19
|
0
|
|
|
|
|
0
|
push(@newValues, $char); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
1
|
50
|
|
|
|
4
|
push(@newValues, '1') if ($carryBit); |
23
|
1
|
|
|
|
|
7
|
return join('', (reverse(@newValues))); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _incChar { |
27
|
1
|
|
|
1
|
|
3
|
my $char = shift; |
28
|
|
|
|
|
|
|
|
29
|
1
|
50
|
|
|
|
6
|
if ($char eq 'Z') { |
30
|
0
|
|
|
|
|
0
|
return '0', 1; |
31
|
|
|
|
|
|
|
} |
32
|
1
|
50
|
|
|
|
4
|
if ($char eq '9') { |
33
|
0
|
|
|
|
|
0
|
return 'A', 0; |
34
|
|
|
|
|
|
|
} |
35
|
1
|
50
|
|
|
|
31
|
if ($char =~ /[A-Z0-9]/) { |
36
|
1
|
|
|
|
|
8
|
return chr(ord($char) + 1), 0; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Purple::Sequence - Generate the next NID in a Sequence of NIDs |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This module contains the code for calculating the next NID |
49
|
|
|
|
|
|
|
in a sequence of Purple Numbers. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $next_nid = Purple::Sequence::increment_nid($current_nid); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 FUNCTIONS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 increment_nid($current_nid) |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Returns the next NID after $current_nid. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 AUTHORS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Chris Dent, Ecdent@burningchrome.comE |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Eugene Eric Kim, Eeekim@blueoxen.comE |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 BUGS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
68
|
|
|
|
|
|
|
C, or through the web interface at |
69
|
|
|
|
|
|
|
L. |
70
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
71
|
|
|
|
|
|
|
your bug as I make changes. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
(C) Copyright 2006 Blue Oxen Associates, all rights reserved. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
78
|
|
|
|
|
|
|
under the same terms as Perl itself. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; # End of Purple::Sequence |