open( USRS, "users.txt" ) or die "no users.txt: $!"; my @emailStrings = ; # let's just read this once close USRS; foreach ( keys %postiniList ) { if ( exists $ldapList{$_} ) { print "$_ exists in ldap\n"; # don't need a "next;" here } else { print "$_ does not exist in ldap\n"; my ( $match ) = grep /\Q$_\E/, @emailStrings; my $emailString = ( split /\t/, $match )[1]; print "deleteuser $emailString\n" } } #### open( USRS, "users.txt" ) or die "no users.txt: $!"; while () { my ($keystring, $emailstring) = (split /\t/, $_)[0,2]; if ( exists $postiniList{$keystring} ) { my $report = "$keystring exists in ldap\n"; unless ( exists $ldapList{$keystring} ) { $report =~ s/ exists / does not exist /; $report .= "deleteuser $emailstring\n" if ( $emailstring ); } print $report; } } close USRS;