#!/usr/bin/perl -w use strict; open FH, 'sipfile.m' or die "can't open file $!"; my ($call1, $sipm); my %data1 = ( ); while () { if (($call1,$sipm) = /(SIP[0-9]).+ (\d\d\d).+$/) { push ( @{data1{$call1}}, $sipm ); } } foreach $call1 (sort keys %data1) { print "$data1{$call1}\n"; } close FH;