Hope you don't mind a few comments on your code.
Firstly, just spliting on commas and removing double quotes is only going to work on the most basic CSV files. Much better to look at using Text::ParseWords (which comes with Perl) or Text::CSV_XS (which doesn't). Both of these will handle more complex CSV files than your code does.
Secondly, it seems a bit wasteful to loop round your @linedata array copying each element separately into a second-level hash. If fact I'd question the use of a hash there at all. If you're using a hash whose keys are low numbered integers, then you're much better off using an array. And as you've already got an array, you can just store a reference to that in your data structure.
$hash{$lineno} = \@linedata;
Hope this is useful.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: build hash from csv file
by davorg
in thread build hash from csv file
by tcf03
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |