469,315 Members | 1,802 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,315 developers. It's quick & easy.

Multiple conditions on a while loop

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
3 17253
4,059 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. unless ($var eq  'A' || $var eq 'B') {
  2.    while(some condition) {
  3.       do something
  4.    }
  5. }
Aug 9 '07 #2
u can give names to the loop and use them;;


LOOP: foreach(@arr){
while($_=~/^#/) {
next LOOP;
Aug 10 '07 #3
1,089 Expert 1GB

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. }
- Miller
Aug 11 '07 #4

Post your reply

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

Similar topics

10 posts views Thread by greedo | last post: by
13 posts views Thread by TheLostLeaf | last post: by
5 posts views Thread by jorgedelgadolopez | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.