Respected Monks,
Please let me know if there is a way that I can insert the logical OR or AND operator in an if loop.
Reason to do this is, I have a condition wherein I need to check if a string contains colon ":" or if the string is not equal to 16 characters, the script should exit.
I know I can write if elsif else, but, am trying to find a way if the || operator, or the && operator can be inserted in an if loop so that I can say something like the following. I tried it out, but its not working.
if ($string=~m/:/g || length($string)!=16) { print "Either : already in string on the length is invalid\n"; exit; } else { work on that string }
Please let me know. Kindly note that I am not a trained programmer and though I have some extremely primitive C knowledge, I am a newbie to Perl, so any mistakes/misconceptions on my understanding of the if loop, please pardon me.
In reply to How to insert || and && in an if loop by perl514
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |