Hello Ammu007,

Welcome to the Monastery. Your task is very very simple. There are plenty of modules for you to use have you tried any so far? Your problem can be resolved even without any modules simple file parsing.

Try and fail and try again as many times necessary until you succeed. This is the only way for you to learn. Show us where you failed and why you can not proceed and we will be more than happy to assist. Give it a try and update your question.

Update: In high lever description the steps that I would follow, open the file using the eof (*.csv), read line by line the file, split each line so you can retrieve individual elements (such as the name and the string), then simple push the data in a perldsc/HASHES OF ARRAYS and voila you are done. This is the way to proceed without using any module(s).

#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; my %HoA; while (<>) { chomp; if (index($_, ',') != -1) { my @fields = split(/,/, ); push @{ $HoA{$fields[0]} }, $fields[5]; } else { warn "Line could not be parsed: $_\n"; } } continue { close ARGV if eof; } print Dumper \%HoA; __END__ $ perl test.pl test.csv $VAR1 = { 'seetha' => [ 'rew' ], 'Anand' => [ 'xyz', 'wer', 'ert', 'tre' ] };

Update2: In case you want to proceed in using module(s) you can simply use Text::CSV.

#!/usr/bin/env perl use strict; use warnings; use Text::CSV; use Data::Dumper; my $csv = Text::CSV->new({ sep_char => ',' }); my %HoA; while (<>) { chomp; if ($csv->parse($_)) { my @fields = $csv->fields(); push @{ $HoA{$fields[0]} }, $fields[5]; } else { warn "Line could not be parsed: $_\n"; } } continue { close ARGV if eof; } print Dumper \%HoA; __END__ $ perl test.pl test.csv $VAR1 = { 'Anand' => [ 'xyz', 'wer', 'ert', 'tre' ], 'seetha' => [ 'rew' ] };

Update3: Sample of *.csv file based on your description.

Anand,1,2,3,4,xyz Anand,2,3,4,5,wer Anand,3,4,4,4,ert seetha,1,2,3,4,rew Anand,2,2,2,2,tre

Looking forward to your update, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: Multiple values for a single key (Updated) by thanos1983
in thread Multiple values for a single key by Ammu007

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.