winracer
11-05-2009, 06:12 AM
My question is I have two arrays that have data and some of the data is the same so I do not want to join the data if the same.
I am not sure how you would code this. here is what I have started and joins and sorts teh data. but there are rolls the same.
I hope I have explained what I need help with.
my %numbers = ();
my $output = "";
open (DATABASE, "$data_file_path_1") || &file_open_error
("$data_file_path", "Display Frontpage", __FILE__, __LINE__);
while (<DATABASE>)
{
$line = $_;
chop $line;
@fields = split (/\|/, $line);
if ($fields[$index_of_status] eq "ok") {
$category = $fields[$index_of_category];
$numbers{$category}++;
}
$numbers1++;
push @goodads2, $line;
}
close (DATABASE);
print qq~
<font size=5><b>$session_username</b> you have <b><font color="#ff0000">$numbers1</font></b> .
</font>
<p>~
open (HITS_FILE, "$location_of_hits_file");
while ($line1 = <HITS_FILE>)
{
chop($line1);
@fields = split(/\|/, $line1);
if ($fields[1] eq "$session_username")
{
push @goodads, $line1;
push @goodads1, $fields[0];
#print qq~ $line1 ~;
}
}
}
else
{
}
close (HITS_FILE);
open(DATAFILE, "$data_file_path_1") ||
&file_open_error("$data_file_path_1",
"Read Database",__FILE__,__LINE__);
while(($line = <DATAFILE>))
{
chop($line);
my @allgoodads = (@goodads2, @goodads); # two sets of data
@sorted = sort {$a <=> $b} @allgoodads; # sort numerically
foreach $line (@sorted)
{
@fields = split(/\|/, $line);
################other code here
last;
} # End of while datafile has data
close(DATAFILE);
print qq~
</table><p>~;
I am not sure how you would code this. here is what I have started and joins and sorts teh data. but there are rolls the same.
I hope I have explained what I need help with.
my %numbers = ();
my $output = "";
open (DATABASE, "$data_file_path_1") || &file_open_error
("$data_file_path", "Display Frontpage", __FILE__, __LINE__);
while (<DATABASE>)
{
$line = $_;
chop $line;
@fields = split (/\|/, $line);
if ($fields[$index_of_status] eq "ok") {
$category = $fields[$index_of_category];
$numbers{$category}++;
}
$numbers1++;
push @goodads2, $line;
}
close (DATABASE);
print qq~
<font size=5><b>$session_username</b> you have <b><font color="#ff0000">$numbers1</font></b> .
</font>
<p>~
open (HITS_FILE, "$location_of_hits_file");
while ($line1 = <HITS_FILE>)
{
chop($line1);
@fields = split(/\|/, $line1);
if ($fields[1] eq "$session_username")
{
push @goodads, $line1;
push @goodads1, $fields[0];
#print qq~ $line1 ~;
}
}
}
else
{
}
close (HITS_FILE);
open(DATAFILE, "$data_file_path_1") ||
&file_open_error("$data_file_path_1",
"Read Database",__FILE__,__LINE__);
while(($line = <DATAFILE>))
{
chop($line);
my @allgoodads = (@goodads2, @goodads); # two sets of data
@sorted = sort {$a <=> $b} @allgoodads; # sort numerically
foreach $line (@sorted)
{
@fields = split(/\|/, $line);
################other code here
last;
} # End of while datafile has data
close(DATAFILE);
print qq~
</table><p>~;