Right now I am attempting to synchronize two data files that are listed by date so that i can make comparisons later on. However I can not seem to print out only the lines where the dates match. At this point I have separated out the data for each file into 2 arrays. I need to find only the dates that are in both arrays and print them out. Any suggestions would be much appreciated.
Here is a sample set of the raw data that I am working with, each file is in the same format:
09/11/2009,00:56:00,51.602,47.894,87,88,0,1032 09/12/2009,00:56:00,57.794,55.796,93,54,0,1023.6 09/13/2009,00:56:00,64.292,62.204,93,66,0,1014.4 09/14/2009,00:56:00,61.592,55.4,80,25,0,1009.6 09/15/2009,00:56:00,58.604,53.798,84,31,0,1009.1 09/16/2009,00:56:00,53.6,48.902,84,45,0,1017
I have split the date into an array for each file. My ultimate goal is to only print lines of code where both files have data. So to do this I wanted to compare the 2 arrays with the elements being the dates.
My initial code looked like this:
foreach $bdate(@bdate){
while (<PL>){
chomp;
@arr = split (/,/);
$pday=$arr[1];
push @pdate, $pday;
if ($bdate eq $pdate){
print "$bdate,$pday\n";
}
}