in reply to Multiple numeric not or compare in if statement
The above code is wrong, is bad, works sometimes. I know this is wrong.
You didn't say in which way it should be wrong. It is not wrong, though it might do something different from your expectations.
This is true, if $sender_transaction_type does not contain the digit 3 or the digit sequence 21. For e.g. "35" or "421" it is false. Maybe you expected it to check for equal / not equal, which it doesn't. But it's not wrong.$sender_transaction_type !~ /3|21/
To check if a string is not in a given set, you may use this expression:
But keep in mind that these are string operations where "3", "3e0" and "3." are all different, contrary to their numerical equality.$sender_transaction_type !~ /^(?:3|21)$/
Greetings,
-jo
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Multiple numeric not or compare in if statement
by choroba (Cardinal) on Jul 02, 2020 at 14:38 UTC |
In Section
Seekers of Perl Wisdom