in reply to Re: regex return true instead of false (precedence)
in thread regex return true instead of false
The easiest way to get around precedence-issues is to define precedence yourself by using (a lot of) brackets. So
will becomeunless (! $args =~ /\-rs(\s+)(\S+)/ && ! $args =~ /\-p(\s+)(\S+)/ && ! + $args =~ /\-P(\s+)(\S+)/) {
I agree it looks a bit confusing, but modern editors help you by showing the matching bracket. And you don't have to think about rules (which might be counter-intuitive (like ! vs =~) or different in other programming languages).unless ((!($args =~ /\-rs(\s+)(\S+)/)) && (!($args =~ /\-p(\s+)(\S+)/) +) && (!($args =~ /\-P(\s+)(\S+)/))) {
HTH, Rata
|
---|
In Section
Seekers of Perl Wisdom