[thelist] Perl file reading problem.....
CDitty
thelist at lists.evolt.org
Fri Jun 14 18:24:00 2002
Hello all. I am trying to read data in from a text file and if one 2
conditions are met, increment a counter. But I am having problems. Half
of it seems to work, but the rest doesn't. All the needed variables are
set by the time it reaches this section.
Here is the file reading code.
# bob@bob.com|165|0|000| This line is how the text file looks.
<code>
open (LOGCOUNT, "crack_log.txt") || die "Can't open crack_log.txt file for
reading.";
flock (LOGCOUNT, 2); # Locks the file
$logcountfile = <LOGCOUNT>; # Assigns the data from the file into an array
# bob@bob.com|165|0|000|
# email address, Play day, win/loss, guess
($emailid,$play) = split(/\|/, $logcountfile);
if(($emailid == $emailaddress) && ($play == $play_day)){
$total_plays++;
}
flock (LOGCOUNT, 8); # Unlocks the file
close(LOGCOUNT);
</code>
$emailid is set after this, but $play is not.
Does anyone see anything wrong with this code?
Thanks
Chris