I hope that was understandable enough. See perlintro warnings strict perlop chomp split perlretut exists print for more.use warnings; use strict; # should be used almost always my %new_strings; # create the hash containing new values while (<>) { # read STDIN and/or files specified on the command line chomp; # cut the newline symbol my ($first,$id) = (split ",",$_,3); # read first two columns and disc +ard all others my $numeric = /(,[\d,]+)$/; # use regexp to match numeric values at t +he end of the line unless (exists $new_strings{$id}) { # if this data was found the firs +t time, initialise the value in the hash $new_strings{$id}="$first,$id"; } $new_strings{$id}.=$numeric; # append the numeric data found } foreach (sort keys %new_strings) { # for each datum found in the secon +d column, in alphabet order print "$new_strings{$_}\n"; # print the full string with all numeric +data found }
In reply to Re: CSV File Parsing
by aitap
in thread CSV File Parsing
by ozman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |