"Goke Aruna" schreef: > #!c:/perl/bin/perl -w
Remove the -w. > use warnings; > use strict; Good! > my $file = 'C:/Perl/20060920_1.csv'; > open FH, $file or die $!; > while(defined($file=<FH>)){ > my @file = split/,/, $file; > print qq($file[0], $file[1], $file[10], $file[9], $file[12], > $file[13]\n); } #!/usr/bin/perl use warnings ; use strict ; my $fn = 'C:/Perl/20060920_1.csv' ; { local ($\, $,) = ("\n", ', ') ; my $sum ; open my $fh, '<', $fn or die "open '$fn': $!" ; while (<$fh>) { s/\s+$// ; # chomps-and-more /^$/ and die "$fn, line $. is empty\n" ; my @data = (split /,/)[0, 1, 10, 9, 12, 13] ; $data[0] or next ; # skips $sum += $data[4] ; print @data ; } print "Total: $sum" ; } (untested) > how can I remove all the excess commas produce? Test the values. See my "$file[0] or next" above for an example. > again i want to sum all the $file[12], how can i achieve this? See my "$sum". -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>