By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,602 Members | 1,457 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,602 IT Pros & Developers. It's quick & easy.

Multiple conditions on a while loop

P: 1
Hi All,

Can anyone help me how to give multiple conditions in a while loop in perl.

For example i have a while loop for which the value of a variable is A or B it should not enter in to the while loop.

Basically i need the condition in the while loop should contains "||". Is it possible?

If not can anyone suggest me an alternative

Thanks & Regards
Kavitha Potnuru
Aug 9 '07 #1
Share this Question
Share on Google+
3 Replies


KevinADC
Expert 2.5K+
P: 4,059
Expand|Select|Wrap|Line Numbers
  1. unless ($var eq  'A' || $var eq 'B') {
  2.    while(some condition) {
  3.       do something
  4.    }
  5. }
  6.  
Aug 9 '07 #2

P: 3
u can give names to the loop and use them;;

eg:-

LOOP: foreach(@arr){
while($_=~/^#/) {
next LOOP;
}
}
Aug 10 '07 #3

miller
Expert 100+
P: 1,089
Kavitha,

Your original premise is not entirely clear. However, maybe this is what you're talking about:

Expand|Select|Wrap|Line Numbers
  1. while ($var ne 'A' && $var ne 'B') {
  2.     # do something
  3. }
  4.  
- Miller
Aug 11 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.