It is hard to tell from that. Assuming you've somehow bound $x to $sth, you are printing it outside the loop not inside. The last is going to break out of the loop and goto the print statment, but $x is still defined so it will be printed.
while ( $sth->fetch() ) { chomp $x; last if ( $x =~ /^foo/ ); print "$x\n"; }
More importantly though. Why arn't you letting your DB pull out the ones that start with foo and get rid of them?
In reply to Re: getting out of a loop
by eric256
in thread getting out of a loop
by o2bwise
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |