http://qs321.pair.com?node_id=1192509


in reply to array of arrays

This can be done using a hash.
#!/usr/bin/env perl use strict; use warnings; open my $fh, '<', 'test_file.txt' or die 'Can not open file'; my %data; while(<$fh>){ chomp $_; my ($key, $val) = split(/\|/, $_); $data{$key} += $val; } foreach my $key ( sort { $a <=> $b } keys %data ){ print "the total is: (".$data{$key}.")\n"; } exit;