in reply to Re: running a loop in background...
in thread running a loop in background...

$mw->update did the trick.....Thanks a lot. but now, of course another problem arises. When the updated file is finally complete, how do I stop 'seek'ing? I tried:
for(;;) { while(<FH>) { $textbox->insert('end', $_); $textbox->yviewScroll(1, "units"); #print substr($_,0,5); $test = $_; if (substr($_,0,5) eq "\>info") {last;} } #sleep $DELAY; $mw->update; if (substr($test,0,5) ne "\>info") { seek(FH, 0, 1);} } }
The 'last' function doesn't seem to work. It should be easy, but being new to perl, I'm having trouble. Can anyone help?

Replies are listed 'Best First'.
Re: Re: Re: running a loop in background...
by Chmrr (Vicar) on Sep 12, 2001 at 01:12 UTC

    Your problem boils down to the following: You have two loops, and you need to exit both of them from the innermost one. There are multiple ways of doing this (need I say that, with Perl?)

    • Label the outermost loop:
      OUTER: for (;;) { while (<FH>) { # stuff last OUTER if substr($_,0,5) eq "\>info"; } # stuff }
    • Use a flag to tell the outer loop we're done:
      for (my $done = 0; !$done;) { while (<FH>) { # stuff ++$done && last if substr($_,0,5) eq "\>info"; } # stuff }

    By the way, watch the capitalization on the methods. I'm not certain if $mw->update will work; I'm more certain $mw->Update will.

     
    perl -e 'print "I love $^X$\"$]!$/"#$&V"+@( NO CARRIER'