#!/usr/bin/perl use warnings; use strict; my $fn; my $cmd_out; my $dn; my @hd; $dn = "/home/"; opendir MYDIR, $dn or die "could not open $dn"; @hd = readdir MYDIR; closedir MYDIR; @hd = grep {!($_ =~ /^\..*$/)} @hd; $fn = "/tilde/lyadmin/user_list.txt"; open FILE, "<", $fn or die "could not open $fn"; while(){ chomp; unless(exists( {map { $_ => 1} @hd}->{$_})){ printf("Deleting user %s\n", $_); `userdel $_`; } } close FILE