#!/usr/bin/perl use Text::CSV; $file = 'testfile.csv'; my $csv = Text::CSV->new(); #Bring in our csv, parse it, and make a hash of filenames (keys) and ID numbers (values) open (CSV, "<", $file) or die $!; my @content; %masterlist; while (){ next if ($. == 1); if ($csv->parse($_)){ my @columns = $csv->fields(); $masterlist{"$columns[0]"} = "$columns[11]"; }else{ my $err = $csv->error_input; print "Failed to parse line: $err"; } } close CSV; # Invert the array twice to get rid of any duplicates that may have gotten into our hash %masterlist = reverse %masterlist; %masterlist = reverse %masterlist; #Show us the output to make sure the keys and values are lined up correctly foreach $key ( keys %masterlist ) { print $key, " => ", $masterlist{$key}, "\n"; }