Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: if statement used in foreach-loop?

by PeterPeiGuo (Hermit)
on Dec 10, 2010 at 05:05 UTC ( [id://876378] : note . print w/replies, xml ) Need Help??

in reply to if statement used in foreach-loop?

The entire difference is centered on one thing - that "next" statement. "next" statement leads you to the next iteration (when the condition is satisfied), and skips the rest steps of this particular iteration. In some sense, your second piece of code is saying the opposite of your first piece (from the print statement's point of view).

Peter (Guo) Pei