> > 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; > > } > > }
That's quite strange.... is this COUNT file single line ? or mulitiple lines ? If single line : 1. The while loop is useless. simplily : $ln = <COUNT> ; ($key, $count) = split(/=/, $ln) if ($ln =~ /BC0012/i); $found = 1 if ($key); 2. However, you didn't do anything to write to the FH and/or printout the $count ?! How can you know this doesn't work ? =) If muliple lines : You will make $found = 0 at the end, if /BC0012/ not existed at the last line. Maybe you want something like this. my $found =0 ; while (...) { # if match, do something $found = 1 } print $found; # so you get the right ans. Both single and multiple lines : 1. use strict and warnings; 2. open (FH, ">file") or +< rather then +>, that talking about some file mode or fix length. It's no use here. But for this case, I still recommand you use the simplest, >. Rgds, Connie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]