[thelist] Perl file reading problem.....

CDitty mail at redhotsweeps.com
Fri Jun 14 19:08:01 CDT 2002


THANK YOU!!!!!!!

I assumed it was looping, but since you said that, I looked at some older
code and figured out what I needed.  THANK YOU!!!!

I'll look at the EQ/== after dinner.  Thanks again

Chris

At 06:55 PM 6/14/2002, you wrote:
>On Fri, Jun 14, 2002 at 06:22:32PM -0500, CDitty wrote:
> > Here is the file reading code.
> > # bob at 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 at 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?
>
>I would do several things. First, I would chop() or
>chomp() the newline off that string. Second, you know
>that you're just reading in one line of that file, right?
>You're not looping over it, you know. Also, I would compare
>strings like "bob at bob.com" with other things by using "eq"
>instead of "==".
>
>I can't immediately see how any of these would cause
>the symptoms you're seeing, but it's possible.
>
>Just to make sure, you are using "-w" and "use strict;",
>aren't you?
>
>Hope it helps.
>
>-Andy
>
>--
>For unsubscribe and other options, including
>the Tip Harvester and archive of thelist go to:
>http://lists.evolt.org Workers of the Web, evolt !




More information about the thelist mailing list