package ReadCSV;
use strict;
use warnings;
use Data::Dumper;
use Text::CSV_XS;
use IO::File;
# Implementation:
sub csv_file_hashref {
my ($filename) = @_;
my $csv_fh = IO::File->new($filename, 'r');
my $csv = Text::CSV_XS->new ();
my %output_hash;
while(my $colref = $csv->getline ($csv_fh))
{
$output_hash{shift @{$colref}} = $colref;
}
return \%output_hash;
}
1;
####
abc xyz,10
xyz pqr,2
pqr stq,0.1
##
##
use strict;
use warnings;
use Data::Dumper;
use ReadCSV;
my $hash_ref = ReadCSV::csv_file_hashref('parameters.conf');
foreach my $key (sort keys %{$hash_ref}){
print qq{$key:};
print join q{,}, @{$hash_ref->{$key}};
print qq{\n};
}