open (URLFHR, 'Url.txt'); open(URLEXFHR,"Url_ex.txt"); while ($ee=) { while ($ee4=) { #print "$ee - $ee4 \n"; $abc4=$ee4; my $sthID = $dbhID->prepare("select MAX(ID) from DI_URL_EXCLUDE where [RULE] ='$ee4' "); $sthID->execute(); $ID = $sthID->fetchrow_array ; #print "$ID \n"; undef( $dbhID ); undef( $sthID ); if ($ee4 =~ /^%/) { $abc4=$ee4; $abc4=~ s/^%//;##first letter # print "$abc4 \n"; } if ($ee4 =~ /%$/) { $abc4=$ee4; $abc4=~ s/%$//; ##Last letter #print "$abc4 \n"; } $ee = quotemeta( $ee ); # To avoid error (Unmatched ) in regex; marked by <-- HERE ),To escape the special characters $abc4 = quotemeta( $abc4 ); if( ($ee) =~ (/$abc4/) ) { #print "In comparision of $ee and $ee4,$ID \n"; open (SIMILARURLFHW, '>>Similar_Url.txt'); print SIMILARURLFHW "$ee\{\|\|\}$ID \n"; close(SIMILARURLFHW); print "\n3"; } } } print "\n4"; my $a; while($a =) { my $UrlName = substr $a,0,index($a,'{||}'); my $EXID = substr $a, index($a,'{||}')+4; my $sthUPEXID = $dbhUPEXID->prepare("UPDATE DI_URL SET EXCLUSIONID =$EXID where URLName = '$UrlName' ");# Updating EXID in emp with ID in emp4 where emp_fname matches in both $sthUPEXID->execute(); }