Brian said:
Sébastien Cottalorda said:
I all,
Here is my problem,
I'd like to store in a hash table those numbers like that:
(123, 124, 13, 145, 2, 25)
%number = ( [snip]
"2" => {
"value" => "OK",
"5" => {
"value" => "OK"
}
}
);
That's a very odd structure - what are you planning to use it for?
I'm planning to make a program that allow me to determine from which country
is a Credit Card.
I've downloaded the BIN table that is basically like this:
MinCC-MaxCC Network(VISA,MASTER,NATIONAL,etc...) Country
The problem is that each interval do not contains the same number of Credit
Card.
ie:
1234000000000000-1234999999999999 VISA USA
1235678900000000-1235678999999999 VISA CHN
2567894561000000-2567894561999999 MASTER TUR
etc...
I then plan to store in memory each interval:
- 1234
- 12356789
- 2567894561
as seen before.
When I try to determine from which country a Credit Card is, I use a
recursive algorithme.
For example: from which country is the credit card number 1234567890123456 ?
1 -> 2 -> 3 -> 4 -> (value=>'OK') ----> Country Found (If, instead of "OK",
I put the country, I can know it).
Another example: from wich country is the credit card number
1239123456789456 ?
1 -> 2 -> 3 -> 9 -> (do not exists) ----> "Country not found"
I hope the BIN Table is not too big.
Whilst a recursive function may seeme the most natural approach acually
an iterative one works perfectly well in this case.
for (123, 124, 13, 145, 2, 25) {
my $r = \\%number;
$r = \$$r->{$_} for split //;
$$r->{value} = 'OK';
}
The only way to become familiar is to read documentation and try.
I agree with that, but I need to quick process the BIN table file, I didn't
have time to read the documentation on this precise problem.
I'd rather ask a very precise question hoping someone helps me.
Note, I didn't ask for my entire problem, I only ask for the number to hash
transformation.
Cheers.
Sébastien