#!/usr/bin/perl -w

use strict;

my ($passwd, $results) = qw< /etc/passwd results.out >;

my %shells;
open FILE, $passwd or die "Cannot open password file: $!\n";
while (<FILE>) {
	chomp;
	next if /ppp/;
	$shells{(split /:/)[-1]} ++;
}
close FILE or die "Cannot close password file: $!\n";

open RES, "> $results" or die "Cannot open '$results' for write: $!\n";
for (sort { $shells{$b} <=> $shells{$a} } keys %shells ) {
	print RES "$_: $shells{$_}\n";
}
close RES or die "Cannot close $results'";
