title: Perl regex & data extraction/manipulation
body: <p>I'm not sure where to start with this one... my client gets stock figures from his supplier but they are now being sent in a different format, here is a sample snippet:</p>
  
  <pre>[["BLK",[["Black","0F1315"]],[["S","813"],["M","1378"],["L","1119"],["XL","1069"],["XXL","412"],["3XL","171"]]],["BOT",[["Bottle","15451A"]],[["S","226"],["M","425"],["L","772"],["XL","509"],["XXL","163"]]],["BUR",[["Burgundy","73002E"]],[["S","402"],["M","530"],["L","356"],["XL","257"],["XXL","79"]]],["DNA",[["Deep Navy","000F33"]],[["S","699"],["M","1161"],["L","1645"],["XL","1032"],["XXL","350"]]],["EME",[["Emerald","0DAB5E"]],[["S","392"],["M","567"],["L","613"],["XL","431"],["XXL","97"]]],["HEA",[["Heather","C0D4D7"]],[["S","374"],["M","447"],["L","731"],["XL","386"],["XXL","115"],["3XL","26"]]],["KEL",[["Kelly","0FFF00"]],[["S","167"],["M","285"],["L","200"],["XL","98"],["XXL","45"]]],["NAV",[["Navy","002466"]],[["S","451"],["M","1389"],["L","1719"],["XL","1088"],["XXL","378"],["3XL","177"]]],["NPU",[["Purple","560D55"]],[["S","347"],["M","553"],["L","691"],["XL","230"],["XXL","101"]]],["ORA",[["Orange","FF4700"]],[["S","125"],["M","273"],["L","158"],["XL","98"],["XXL","98"]]],["RED",[["Red","FF002E"]],[["S","972"],["M","1186"],["L","1246"],["XL","889"],["XXL","184"]]],["ROY",[["Royal","1500CE"]],[["S","1078"],["M","1346"],["L","1102"],["XL","818"],["XXL","135"]]],["SKY",[["Sky","91E3FF"]],[["S","567"],["M","919"],["L","879"],["XL","498"],["XXL","240"]]],["SUN",[["Sunflower","FFC700"]],[["S","843"],["M","1409"],["L","1032"],["XL","560"],["XXL","53"]]],["WHI",[["White","FFFFFF"]],[["S","631"],["M","2217"],["L","1666"],["XL","847"],["XXL","410"],["3XL","74"]]]]</pre>
  
  <p>Firstly the inital <code>[</code> and end <code>]</code> can be removed</p>
  
  <p>Then it needs be be broken down into segments of colours, i.e.:</p>
  
  <pre>["BLK",[["Black","0F1315"]],[["S","813"],["M","1378"],["L","1119"],["XL","1069"],["XXL","412"],["3XL","171"]]]</pre>
  
  <p>The BLK is needed here, the next block <code>[["Black","0F1315"]]</code> can be disregarded.</p>
  
  <p>Next I need to take the stock data for each size <code>["S","813"]</code> etc</p>
  
  <p>Therefore I should have a data such as:</p>
  
  <pre><code> $col = BLK
   $size = S
   $qty = 813
  
   $col = BLK
   $size = M
   $qty = 1278
  </code></pre>
  
  <p>and repeat this segment for every colour seqment in the data.</p>
  
  <p>The amount of colour segments in the data will vary, as will the amount of sizing segements within.  Also the amount of sizing segments will vary colour to colour, i.e. there maybe 6 sizes for BLK but only 5 for RED</p>
  
  <p>The data will be written out while in the loop for these so something like <code>print "$col:$size:$qty"</code> will be fine as this would then be in a format ready to be processed.</p>
  
  <p>Sorry for the long message, I just can't seem to get my head round this today!!</p>
  
  <p>Regards,</p>
  
  <p>Stu</p>