in reply to working with a hash

You could use a hash rather than an array to more easily get your unique left-column items.

use strict; use warnings; use Data::Dumper; my %uniques = (); while ( <DATA> ) { chomp; my ($key, $value) = split m{\|}; $uniques{$key} += $value; } print Data::Dumper->Dump([\%uniques], [q{*uniques}]); __DATA__ 10|10 20|20 30|30 10|100 15|15 50|50 15|150

This produces

%uniques = ( '50' => 50, '30' => 30, '10' => 110, '15' => 165, '20' => 20 );

I hope this is helpful.

Cheers,

JohnGG