#!/usr/bin/perl

open PASSWD, "/etc/passwd" or die "$!";

while (<PASSWD>) {
 /^([^:]+):[^:]+:[^:]+:[^:]+:([^,:]+)/;
 $p{($2 ne '')?$2:$1}=$1;
}
foreach (sort keys %p) {
  print "$_\t$p{$_}\n";
}

