Dear monks,

I am trying to organise a number of lists of item serial numbers (stored in a small number of files). The problem I have is each unit can have up to 5 variations of it's serial number stored across the multiple files (poorly designed system but there we go). Let me provide an example below:

012212316000140 = Full 15 digit serial. This comprises of month and year (0122), core serial (1231600014), check digit (0)
01221231600014 = 14 digit version (minus the last check digit)
2212316000140 = 13 digit version 1 (minus the leading 2 month digits but including the last check digit)
1221231600014 = 13 digit version 2 (minus the leading zero for the month and minus the check digit). These entries would need to be corrected to add the leading zero and therefore become the 14 digit version
221231600014 = 12 digit version (minus both leading month and last check digit)
1231600014 = 10 digit version (just the core serial)

As you can see this is a nightmare and different areas use different versions of the serial. My first step is to try and make a hash using the base 10 digit serial as the key, and then have key value pairs for each of it's possible forms. For example:

{ '1231600014' => { '15' => '012212316000140', '14' => '01221231600014' } }

The other option which might be easier to manage within a JSON file is to store each core serial along with it's leading month and year, and check digit as seperate keys for example

{ '1231600014' => { 'check' => '0', 'month' => '01', 'year' => '22' } }

The main thing that is giving me a headache is processing each serial and working out if we already have an entry for it, as well as valid entries for each possible form

Any assistance would be greatly appreciated. I fear I am overcomplicating this in my head. I'm happy to provide more information and clarity if required

Thanks!


In reply to Merging multiple variations of a serial number by Doozer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.