while ( ) { chomp; (my $txnid,my $date,my $custid,my $amount, my $productc, my $subc, my $city, my $state, my $mode) = split(","); my $key_to_reduce = join ".", "$subc", "$state"; print "$key_to_reduce\t$amount\n"; } #### while ( ) { # not needed if you don't use last field # chomp; # one 'my' for a list; grab only the needed fields my ($amount, $subc, $state) = (split/,/)[3,5,7]; # no need for join: my $key_to_reduce = "$subc.$state"; print "$key_to_reduce\t$amount\n"; }