open(COUNT,"<count.dat") or die "Could not open countfile: $!"; while(<COUNT>) { chomp; if($_ =~ /BC0012/) { my($key,$count) = split('=',$_); $count++; print "$count\n"; } } close(COUNT);
"David Gerler" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > okay... seems tonight is the night for regex... I have been looking at the > emails that have been flying all evening.. I have tried to implement what I > see. > > For some reason, mine don't work. Others say what they got in the email > works. I try it and it don't. > > The plan for the code is to read a count (looks like "BC0012=2") and add one > and replace it in the file. When I execute it, It never enters the while > loop. > > Here's my code. This is the applicable part. I do close the file later. I > have also tried opening the file with +< with any luck. > > sub count { > open (COUNT, "+>./count.dat") or die "cannot open countfile: $!"; > flock(COUNT, 2); > > while (<COUNT>){ > if (m/BC0012/i){ > ($key, $count) = split('=',$_); > $found = 1; > $count++; > } else { > $found = 0; > } > > } > > Any help is appreciated! > > > > David Gerler > Gerler Enterprises > PO BOX 16357 > Chesapeake VA 23328 > http://www.GerlerEnterprises.com/ > > Nationwide Dial-up from $12.45 > http://www.EasySitesForLess.com/ > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]