#!/usr/bin/perl
#
# Written 1999 by Christian Ordig <chr.ordig@gmx.net>
#
$count=0;

open (DATA,"$ENV{HOME}/addresses") || die ("File not found");
    while (<DATA>) {
	chop;
	if (/@ARGV/i) {
	    ($name, $email, $comment) = split(/\;/);
#	    print ("$email\t$name\t$comment\n");
	    push (@out,"$email\t$name\t$comment\n");
	    $count=$count+1;
	}


    }
close (DATA);

sub by_name {
    $_=$a;
    ($t,$name1,$t)=split(/\t/);
    $_=$b;
    ($t,$name2,$t)=split(/\t/);
    uc($name1) cmp uc($name2);
}

@out=sort {by_name} @out;
print ("$count matches found...\n");
print (@out);
