In the spirit of TMTOWTDI:
$found=0; open(RAFFLE_DAT,"< tickets.dat") || die "tickets.dat is not found."; while(<RAFFLE_DAT>) { chop; if ($tickennum,$emailaddr)=split(/::/,$line)) if ($emailaddr eq $email) { $found=1; last; } } } close (RAFFLE_DAT) || die "Could not close tickets.dat\n"; if ($found) { &bademail(); } else { &goodemail; }
Instead of the chop, you could replace the sixth line with:
if ($emailaddr eq "$email\n") { $found=1; last; }
As an aside, if the ticket numbers are arbitrary, you could always not even use a $tickennum, but just have a list of emails in the file, and the "ticket number" would be their line number:
## Assigns email address to each ticket number $x=0; while(<RAFFLE_DAT>) { chop; $ticket{$x++}=$_; ## or push(@ticket, $_); }
In reply to Re: Wondering novice...
by turnstep
in thread Wondering novice...
by threepts
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |