for (@csv2) { # for data in @csv2 array my ($title) = $_ =~ /^.+?,\s*([^,]+?),/; $csv2hash{$_} = $title; }