develooper Front page | perl.beginners | Postings from December 2002

RE: Using while ( -e $file )

Thread Previous
Kipp, James
December 26, 2002 13:57
RE: Using while ( -e $file )
Message ID:
> The problem is that the file test does not seem to be re-evaulated 
> each loop. If I delete the file after the loop has started it 
> drops into the. SHRUNK test. I would think it would drop out of the 
> while loop.  
> while ( -e $tfile ) { 
>       $SIZE = (-s "$TEMPFILE") /1024;
>       if ( $SIZE > $PSIZE ) {
>          $PSIZE="$SIZE";
>          print "$TEMPFILE Size = $SIZE Kb\n";
>       } elsif ( $SIZE < $PSIZE ) {
>          print "$TEMPFILE SHRUNK! from $PSIZE to $SIZE  Kb\n";
> 	}
> 	sleep(10); 
> }

so are you saying the file being tested in the while loop ($tfile) is being
deleted during the sleep? after the while test evaluates as true(the file
exists), it will continue through the while loop even though you delete
during the loop. not sure what you are trying to do here. you can do further
test in the loop and add things like break or next or lock the file. can you
post more of the code? hurry I am leaving for the day in 10 mins :-)

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About