linkexchange
Programmer
Hi! I'm not a professional programmer in perl, but I can write a little bit! I'd like to get this loop working right.
I have 2 files, one is just a sorted list of email addresses. The other contains another list with 9 columns and column 9 has the email address in it. I ran every email in the big list through an email verifier program and the email list is the results from that program. It's reduced down quite a bit. So now I need to write out a new file and compare each email in the email list to the email in the big file. For each email in the email list I need to print out certain columns in the big file. If an email in the big file doesn't match the current email, you skip it so that I have rows with valid email addresses. This is the part I'm not doing right in my loop.
#!/usr/bin/perl
my $emailurl="EMail.txt";
my $path="C:1millrealtors/";
my $outfile="fileout.txt";
my @newurl='';
##########################################################
# open file of emails
open(OUT,">$path$outfile") || die ("Can't open file!");
open(FILE,"1millrealtors/emails.txt") || die ("Can't open file!");
my @emailfile =<FILE>;
close FILE;
# open complete file
open(FILE,"./1millrealtors/CA154135.csv") || die ("Can't open file!");
my @bigfile =<FILE>;
close FILE;
print "Content-type: text/html\n\n";
my $j=0;
for(@emailfile) {
chomp;
for(@bigfile) {
chomp;
my @bigfilerow=split(',',$_);
# print $bigfilerow[9];
#exit;
if ($bigfilerow[9] eq $emailfile[0]) {
#print OUT bigfile[0] . "," . bigfile[1];
print $bigfilerow[0] . "," . $bigfilerow[8] . "," . $bigfilerow[9] . "\n" ;
last;} else {
next; }
}
}
I have 2 files, one is just a sorted list of email addresses. The other contains another list with 9 columns and column 9 has the email address in it. I ran every email in the big list through an email verifier program and the email list is the results from that program. It's reduced down quite a bit. So now I need to write out a new file and compare each email in the email list to the email in the big file. For each email in the email list I need to print out certain columns in the big file. If an email in the big file doesn't match the current email, you skip it so that I have rows with valid email addresses. This is the part I'm not doing right in my loop.
#!/usr/bin/perl
my $emailurl="EMail.txt";
my $path="C:1millrealtors/";
my $outfile="fileout.txt";
my @newurl='';
##########################################################
# open file of emails
open(OUT,">$path$outfile") || die ("Can't open file!");
open(FILE,"1millrealtors/emails.txt") || die ("Can't open file!");
my @emailfile =<FILE>;
close FILE;
# open complete file
open(FILE,"./1millrealtors/CA154135.csv") || die ("Can't open file!");
my @bigfile =<FILE>;
close FILE;
print "Content-type: text/html\n\n";
my $j=0;
for(@emailfile) {
chomp;
for(@bigfile) {
chomp;
my @bigfilerow=split(',',$_);
# print $bigfilerow[9];
#exit;
if ($bigfilerow[9] eq $emailfile[0]) {
#print OUT bigfile[0] . "," . bigfile[1];
print $bigfilerow[0] . "," . $bigfilerow[8] . "," . $bigfilerow[9] . "\n" ;
last;} else {
next; }
}
}