And reading the data can be so easy with Text::CSV_XS. In my perception even easier than with your snippet. Mind that you have two trailing columns that you do not use.
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, $seria +l, $cardno, $currentsw, $os_ver, $epg_ver, $boxty +pe, $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, }; }
In reply to Re: .csv file in to hash of hashes for a Berkley DB (for a hash newbie)
by Tux
in thread .csv file in to hash of hashes for a Berkley DB (for a hash newbie)
by Doozer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |