line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::SWIFT; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
58850
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
78
|
|
4
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
101
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
2306
|
use Locales ; |
|
2
|
|
|
|
|
36680
|
|
|
2
|
|
|
|
|
506
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Business::SWIFT - Validate SWIFT/BIC Bank identifiers. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.01 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This module implements the SWIFT BIC format validation. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
It checks if the given SWIFT BIC code is well-formed according |
25
|
|
|
|
|
|
|
to the ISO 9362 Specification. It does not check if the code is a |
26
|
|
|
|
|
|
|
valid actual bank code. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Business::SWIFT; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
if ( Business::SWIFT->validateBIC('DEUTDEFF') ){ |
32
|
|
|
|
|
|
|
.. do stuff .. |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Based on the following specification: |
37
|
|
|
|
|
|
|
http://en.wikipedia.org/wiki/ISO_9362 |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 FUNCTIONS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 validateBIC |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Returns a true value if the given BIC code is correct. False otherwise. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Code letters have to be uppercase. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
This is a class method. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Usage example: |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
if ( Business::SWIFT->validateBIC('DEUTDEFF') ){ |
53
|
|
|
|
|
|
|
.. do stuff .. |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub validateBIC{ |
60
|
14
|
|
|
14
|
1
|
44
|
my ( $class , $candidate ) = @_ ; |
61
|
|
|
|
|
|
|
|
62
|
14
|
|
|
|
|
24
|
my $candLength = length($candidate) ; |
63
|
14
|
100
|
100
|
|
|
80
|
if( ( 8 != $candLength ) && ( 11 != $candLength ) ){ |
64
|
1
|
|
|
|
|
6
|
return 0; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
13
|
|
|
|
|
71
|
my ( $bankCode , $countryCode , |
68
|
|
|
|
|
|
|
$locationCode , $branchCode ) = ( $candidate =~ /^([A-Z]{4})([A-Z]{2})([A-Z0-9]{2})([A-Z0-9]{3})?/ ); |
69
|
13
|
100
|
|
|
|
38
|
if( ! $bankCode ){ |
70
|
2
|
|
|
|
|
10
|
return 0; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
11
|
|
|
|
|
45
|
my $en = Locales->new( "en" ); |
74
|
|
|
|
|
|
|
|
75
|
11
|
100
|
|
|
|
11489
|
if ( ! $en->get_territory_from_code( $countryCode ) ){ |
76
|
1
|
|
|
|
|
43
|
return 0; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
10
|
50
|
|
|
|
209
|
if ( ! $locationCode ){ |
80
|
0
|
|
|
|
|
0
|
return 0; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
10
|
100
|
100
|
|
|
47
|
if ( ( $candLength == 11 ) && ( ! $branchCode ) ){ |
84
|
1
|
|
|
|
|
6
|
return 0; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
## All is correct |
88
|
9
|
|
|
|
|
46
|
return 1; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Jerome Eteve C<< >> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
99
|
|
|
|
|
|
|
C, or through the web interface at |
100
|
|
|
|
|
|
|
L. |
101
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
102
|
|
|
|
|
|
|
your bug as I make changes. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SUPPORT |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
perldoc Business::SWIFT |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
You can also look for information at: |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=over 4 |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
L |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * CPAN Ratings |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
L |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * Search CPAN |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
L |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Copyright 2009 Careerjet, all rights reserved. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
139
|
|
|
|
|
|
|
under the same terms as Perl itself. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; # End of Business::SWIFT |