Gossamer Forum
Home : General : Perl Programming :

How to exit a "foreach" loop early?

Quote Reply
How to exit a "foreach" loop early?
I'm doing a little mod of DBMan to check for unacceptable words. What I have so far is

Quote:
foreach $dirty_word (@dirty_words) {
if (lc($in{$col}) =~ /$dirty_word/) {
push(@input_err, "$col (Includes a banned word.");
}
}

As soon as it comes up with one unacceptable word, there's no point in checking for more. How do I exit the loop early?

Thanks much!



------------------
JPD
Subject Author Views Date
Thread How to exit a "foreach" loop early? JPDeni 29648 Oct 18, 1998, 12:35 PM
Post Re: How to exit a "foreach" loop early?
Mark Badolato 29470 Oct 18, 1998, 1:06 PM
Post Re: How to exit a "foreach" loop early?
JPDeni 29461 Oct 18, 1998, 1:09 PM