| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Business::CUSIP::Random; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4876
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
42
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use Business::CUSIP; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
549
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Business::CUSIP::Random - Generate random CUSIP numbers for testing |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Business::CUSIP::Random; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $cusip; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$cusip = Business::CUSIP::Random->generate; # returns a Business::CUSIP object |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# or... |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$cusip = Business::CUSIP::Random->generate_string; # returns a string |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Generates a random CUSIP (Committee on Uniform Security Identification Procedures) number for use in testing. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 generate |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 generate_string |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Returns a randomly-generated, valid CUSIP number. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
generate() returns a Business::CUSIP object, while generate_string() returns a string. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Takes the following optional parameter as a hash: |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=over 4 |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item * B |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
If true, the CUSIP generated will follow the format defined for fixed-income securities. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=back |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub generate { |
|
52
|
1001
|
|
|
1001
|
1
|
585320
|
my ($class, %params) = @_; |
|
53
|
|
|
|
|
|
|
|
|
54
|
1001
|
|
|
|
|
4181
|
my $cusip = $class->rand_issuer_number(%params) . |
|
55
|
|
|
|
|
|
|
$class->rand_issue_number(%params); |
|
56
|
1001
|
|
|
|
|
8212
|
my $cusip_obj = Business::CUSIP->new($cusip, $params{fixed_income}); |
|
57
|
1001
|
|
|
|
|
8068
|
$cusip .= $cusip_obj->check_digit; |
|
58
|
1001
|
|
|
|
|
76290
|
$cusip_obj->cusip($cusip); |
|
59
|
1001
|
|
|
|
|
6894
|
return $cusip_obj; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub generate_string { |
|
63
|
1
|
|
|
1
|
1
|
438
|
my $class = shift; |
|
64
|
1
|
|
|
|
|
4
|
return $class->generate(@_)->cusip; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 rand_issuer_number |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Returns a random CUSIP issuer number |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Takes the following optional parameter as a hash: |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=over 4 |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item * B |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
If true, the issuer number generated will follow the format defined for fixed-income securities. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=back |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub rand_issuer_number { |
|
84
|
1001
|
|
|
1001
|
1
|
1875
|
my ($class, %params) = @_; |
|
85
|
1001
|
|
|
|
|
3154
|
return $class->_pick(3, 0..9) . $class->_pick(3, 0..9, 'A'..'Z'); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 rand_issue_number |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Generates a random CUSIP issue number. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Takes the following optional parameter as a hash: |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=over 4 |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item * B |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
If true, the issue number generated will follow the format defined for fixed-income securities. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=back |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub rand_issue_number { |
|
105
|
1001
|
|
|
1001
|
1
|
2083
|
my ($class, %params) = @_; |
|
106
|
1001
|
100
|
|
|
|
8393
|
return $params{fixed_income} ? $class->_pick(2, 'A'..'H', 'J'..'N', 'P'..'Z', 2..9) |
|
107
|
|
|
|
|
|
|
: $class->_pick(1, 10..88); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _pick { |
|
111
|
3003
|
|
|
3003
|
|
15445
|
my ($class, $count, @chars) = @_; |
|
112
|
3003
|
|
|
|
|
4776
|
my $res = ''; |
|
113
|
3003
|
|
|
|
|
13994
|
$res .= $chars[rand @chars] for (1..$count); |
|
114
|
3003
|
|
|
|
|
20268
|
return $res; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Business::CUSIP |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 AUTHORS |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Michael Aquilina |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Grant Street Group |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Copyright (C) 2011 Michael Aquilina. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
|
136
|
|
|
|
|
|
|
|