Re: Breaking out of foreach loop

2001-09-02 Thread baby lakshmi
Hi Chris, Use loop breaks such as last, next, goto etc eg @arr=qw(1 3 4 2 4 5); foreach $number(@arr) { last if($number == 2); print "$number"; } HTH Regards Babylakshmi M _ Get your FREE download of MSN Explorer at http://

Re: Breaking out of foreach loop

2001-08-06 Thread Rachel Coleman
> Can someone tell me how I can break out of a foreach loop before the end? Use the 'last' command. See http://www.perldoc.com/perl5.6/pod/func/last.html for an explanation of how to use it. It works for breaking out of any loop e.g. foreach, while, until. Best wishes, Rachel -- To unsu

Re: Breaking out of foreach loop

2001-08-05 Thread Jos I. Boumans
for (1..10) { last if /3/; print; } you'll notice this printing '12' so 'last' breaks out of the loop if the condition is met hth Jos Boumans - Original Message - From: "Webmaster" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, August 05, 2001 7:31 PM Subject: Breaking out