On 8/7/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote: snip > open (my $OUT_FILE,"+>","$write_path/$file.out") or die $!; > > while (my($key, $value) = each %hash) > { > print $OUT_FILE $value; > } > my $lines = 0 ; > $lines++ while<$OUT_FILE> ; > > print $LOG_FILE "Count of cdrs after removing > duplicates = $lines" ; snip > At last I am trying to get the count of lines of my OUT_FILE. It is giving me > the result as 0, which is not true. > Where am i doing a mistake? snip
After you are finished writing to the file the file pointer is at the end of the file. Any reads will immediately return EOF. So, you need to seek to the beginning of the file (seek $OUT_FILE, 0, 0;), but why not just increment $lines as you write them? Or, better yet, use keys like this print $LOG_FILE "Count of cdrs after removing duplicates = " . (keys %hash) . "\n"; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/