Hi,

Important to note that there are repeated values, which is the case for the provided sample output, (ie info 01 = info11, info02 = info12, etc.), but this is not always the case.

Although your sample data does not correspond with this comment, you should consider that hashes have unique keys.

use strict; use warnings; use feature 'say'; use Data::Dumper; my %hash; while (<DATA>) { chomp; my @items = split ','; $hash{ $items[0] } = $items[1]; } say Dumper \%hash; __DATA__ a,b a,c x,y
Output:
$ perl 11132513.pl $VAR1 = { 'a' => 'c', 'x' => 'y' };

Hope this helps!


The way forward always starts with a minimal test.

In reply to Re: Creating a Multi Level Hash from CSV by 1nickt
in thread Creating a Multi Level Hash from CSV by workInProgress12

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