You could use a hash-of-hashes data structure (perldsc)
use warnings; use strict; my %data; while (<DATA>) { chomp; my @tokens = split /,/; my %hash; $hash{symbol } = $tokens[0]; $hash{timeStamp } = $tokens[2]; $hash{status } = $tokens[3]; $hash{bid } = $tokens[4]; $hash{bidVol } = $tokens[5]; $hash{ask } = $tokens[6]; $hash{askVol } = $tokens[7]; $data{$tokens[1]} = \%hash; } use Data::Dumper; $Data::Dumper::Sortkeys=1; print Dumper(\%data); # FILE1: __DATA__ ESM3,2285319,Q,13:58:50.744000,Q,WIDE,1549.250000,656,1549.500000,522, +0.000000,0.000000,0.000000,105,67,N,CME,CME ESM3,2285247,T,13:58:49.986000,SELL,1549.250000,2,0,1738560,,U ESM3,2285320,Q,13:58:50.749000,Q,WIDE,1549.250000,656,1549.500000,524, +0.000000,0.000000,0.000000,105,68,N,CME,CME ESM3,2285321,Q,13:58:50.750000,Q,WIDE,1549.250000,655,1549.500000,524, +0.000000,0.000000,0.000000,104,68,N,CME,CME ESM3,2285325,Q,13:58:50.801000,Q,WIDE,1549.250000,655,1549.500000,522, +0.000000,0.000000,0.000000,104,67,N,CME,CME ESM3,2285326,Q,13:58:50.802000,Q,WIDE,1549.250000,656,1549.500000,522, +0.000000,0.000000,0.000000,105,67,N,CME,CME ESM3,2285328,Q,13:58:50.831000,Q,WIDE,1549.250000,667,1549.500000,522, +0.000000,0.000000,0.000000,106,67,N,CME,CME ESM3,2285329,Q,13:58:50.832000,Q,WIDE,1549.250000,1504,1549.500000,522 +,0.000000,0.000000,0.000000,107,67,N,CME,CME ESM3,2285330,Q,13:58:50.833000,Q,WIDE,1549.250000,1505,1549.500000,522 +,0.000000,0.000000,0.000000,108,67,N,CME,CME ESM3,2285331,Q,13:58:50.833000,Q,WIDE,1549.250000,1506,1549.500000,522 +,0.000000,0.000000,0.000000,109,67,N,CME,CME ESM3,2285332,Q,13:58:50.833000,Q,WIDE,1549.250000,1506,1549.500000,520 +,0.000000,0.000000,0.000000,109,66,N,CME,CME ESM3,2285333,Q,13:58:50.833000,Q,WIDE,1549.250000,1506,1549.500000,519 +,0.000000,0.000000,0.000000,109,65,N,CME,CME ESM3,2285334,Q,13:58:50.833000,Q,WIDE,1549.250000,1507,1549.500000,519 +,0.000000,0.000000,0.000000,110,65,N,CME,CME

Here's a snippet of the output:

$VAR1 = { '2285247' => { 'ask' => '2', 'askVol' => '0', 'bid' => 'SELL', 'bidVol' => '1549.250000', 'status' => '13:58:49.986000', 'symbol' => 'ESM3', 'timeStamp' => 'T' }, '2285319' => { 'ask' => '1549.250000', 'askVol' => '656', 'bid' => 'Q', 'bidVol' => 'WIDE', 'status' => '13:58:50.744000', 'symbol' => 'ESM3', 'timeStamp' => 'Q' },

In reply to Re: Help creating HASH for file comparison by toolic
in thread Help creating HASH for file comparison by jb60606

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.