#!/usr/bin/perl
my $pattern = $ARGV[0];
open( IN, "</d/kde/src/4/kde-common/accounts") or die;
binmode( IN, ":utf8" );
while (<IN>) {
	if ( /$pattern/i ) {
		if (m/^(\S*)\s*(.*)\s+(\S+)\s*$/) {
			my ($nick, $name, $email) = ($1,$2,$3);
			$name =~ s/[ ]*$//; #remove trailing space
			print "$nick $name <$email>\n";
		} else {
			print;
		}
	}
}
close IN;
