#!/usr/bin/perl use strict; use DBI; use Data::Dumper; my $dbh = get_dbh(); #as required # get mysql records my $sql = "SELECT TRIM(mid),type FROM table WHERE type != 'NA'"; my $sth = $dbh->prepare($sql); $sth->execute(); my %table = (); while (my ($mid,$type) = $sth->fetchrow_array){ $table{$mid} = $type; } #print Dumper \%table; # check ldap records my @ldap = (" 4\r\n"," 5 "," 6 ",7,8,9,1,2,3); #print Dumper \@ldap; my @new_ldap = (); for my $id (@ldap){ #chomp $id; $id =~ s/\s//g; if (exists $table{$id}){ print "[$id] removed\n"; } else { push @new_ldap,$id; } } #print Dumper \@new_ldap;