use Text::CSV_XS; my $stbdetails = "stbdetails.csv"; open my $fh, "<", $stbdetails or die "$stbdetails: $!"; my $csv = Text::CSV_XS->new ({ binary => 1, auto_diag => 1 }); $csv->bind_columns (\my ( $location, $date_active, $manufacturer, $hwver, $serial, $cardno, $currentsw, $os_ver, $epg_ver, $boxtype, $designation, $boxip, $boxmac, $codedate, $_flag, $_date, )); my %hash; while ($csv->getline ($cfh)) { $hash{$location} = { "Date Active" => $date_active, "Manufacturer" => $manufacturer, "HW Version" => $hwver, "Serial" => $serial, "Card No" => $cardno, "Current Software" => $currentsw, "OS Version" => $os_ver, "EPG Version" => $epg_ver, "Box Type" => $boxtype, "Designation" => $designation, "IP Address" => $boxip, "MAC Address" => $boxmac, "Code Date" => $codedate, }; }