use strict;
use DBI;
#my $master_dsn = 'DBI:mysql:moneycontrol:172.29.44.5 ';
#my $master_db_user = 'crawlmc';
#my $master_db_paswd = 'craWLMC';

my $master_dsn = 'DBI:mysql:connect:172.29.44.253 ';
my $master_db_user = 'irconnectdb';
my $master_db_paswd = '13c077ect~131';


my $master_dbh = DBI->connect ($master_dsn, $master_db_user, $master_db_paswd, {mysql_auto_reconnect => 1});

my $master_sth = $master_dbh->prepare ("SELECT entityname from wiki_full_list");

$master_sth->execute ();

while (my ($entityname) = $master_sth->fetchrow_array ())
{
	next if $entityname eq '';
        next if $entityname !~ m/^[A-Za-z0-9\. ]*?$/;
	$entityname =~ s/\(/\\(/;
        $entityname =~ s/\)/\\)/;
	print $entityname . "\n";
}

#exit;
$master_sth->finish;
#system ("date");
open (FILENAME, "/var/www/cron/mc/172_30_11_23/entities_temp.txt") or die "could not open file";
my $entList = '';
my @values = '';

foreach my $temp (<FILENAME>)
{
	my @aValues = split(/=/, $temp);
        chomp(@aValues);
	$temp = trim(@aValues[0]);
	#print $temp , "\n";
	next if $temp eq '';
	next if $temp !~ m/^[A-Za-z0-9\. ]*?$/;
	
	$temp =~ s/\(/\\(/;
        $temp =~ s/\)/\\)/;
	print $temp , "\n";
}

exit;

sub trim($)
{
        my $string = shift;
        $string =~ s/^\s+//;
        $string =~ s/\s+$//;
        return $string;
}
