OK - here is how you might want to proceed:
- Obviously, you are only interested in the first three letters of the 2nd column ($columns[1]). You can extract them with substr or with a regex.
- If it comes to grouping, a hash is the thing you want. I propose to use column 1 and the 3 letters of column 2 as a key.
- As a value, you should add the values of column 3 each time you find it
- At the end, just loop over the hash and print all pairs of keys/values
A code-fragment (following your start) could look like
my $key = $columns[0].", ".$columns[1]; # supposed columns[1] has a
+lready been reduced to its first 3 letters
$myHash { $key } += $columns[2];
HTH, Rata