in reply to Help with parsing through a comma delimted file
I think I did it without use of libraries ... :) Sozinopen ( IN, "myinput.csv" ) || die "$!\n"; my %data; #data is a hash table. key is COUNT, and vals are #key . Type . Error Message vals. Note that there isn't a # very good hash value associated with the set of data, #as COUNT probably isn't guaranteed to be unique ... while (<IN>) { #split on the comma my ( $count, $type, $errMsg ) = split( /,/ ); print "collision!?!\n" if exists $data{$count . $type . $errMsg }; $data{$count . $type . $errMsg} = ($type, $errMsg); #ref to list } my @sortedKeys = sort keys $data; print "COUNT\tType\tError Message\n"; foreach my $key ( $data ) { print "$key\t$data->{$key}[0]\t$data->{key}[1]\n"; }
|
|---|