Here is my input on it, which I am pretty new to hashes as well so please keep that in mind ;)

use strict; use warnings; use Data::Dumper; my %hash = (); my $i = 0; while (<DATA>) { chomp; my ( $sec_id, $Initial_shares ) = split( /,/, $_ ); $hash{secid}{$i} = $sec_id; $hash{init_sh}{$i} = $Initial_shares; $i++; } #print Dumper \%hash; foreach my $outter_key ( keys %hash ) { print "$outter_key => {\n"; while ( my ( $inner_key, $inner_value ) = each $hash{$outter_key} +) { print "\t\t" . qq('$inner_key') . " => " . qq('$inner_value') +. "\n"; } print "};\n\n"; } __DATA__ 002826,3777 0028262,3777 0028262,3777 0028262,3777 0028262,3777 0028262,3777

Outputs:

init_sh => { '4' => '3777' '1' => '3777' '3' => '3777' '0' => '3777' '2' => '3777' '5' => '3777' }; secid => { '4' => '0028262' '1' => '0028262' '3' => '0028262' '0' => '002826' '2' => '0028262' '5' => '0028262' };

This method looks like it would be a sure fire way to keep track of what belonged to what as well.

EDIT: I dont know why, but I thought OP was looking for a solution with hashes... anyway on a side note, while I was messing around with this, I did figure out another way to load modules haha;

EDIT: Updated code.


In reply to Re: Get CSV data and convert it to other format data dynamically. by james28909
in thread Get CSV data and convert it to other format data dynamically. by ash1351

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.