|Perl Monk, Perl Meditation|
Parsing credit card track databy Ovid (Cardinal)
|on Aug 22, 2002 at 22:55 UTC||Need Help??|
Ovid has asked for the
wisdom of the Perl Monks concerning the following question:
Does anyone have any suggestions for a robust method of parsing credit card track data? Background: I need to be able to print credit card numbers on receipts, with all but the last four number turned to asterisks. If the credit card is swiped through the reader, as opposed to the number being keyed in by hand, then I get the magnetic "track data" (which you can read about here). Unfortunately, I can't seem to find clear specs on this. Further, American Express seems to have a slightly different format than other credit cards.
Based upon a combination of the above article and an actual examination of various credit cards in the office, I have the following snippet of code:
Unfortunately, this is just an ad hoc solution and I would love to find something more robust. I couldn't find any CPAN modules and the oracle let me down.
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.