Hi Monks, I have a string and I want to add something to it, if it does not already have it.
I though that the following code, should do it:
unless ($args =~ /\-rs(\s+)(\S+)/ && $args =~ /\-p(\s+)(\S+)/ && $args
+ =~ /\-P(\s+)(\S+)/) {
$args .= " --rs $str";
}
The idea:
if ($args =~ /\-rs(\s+)(\S+)/ || $args =~ /\-p(\s+)(\S+)/ || $args =~
+ /\-P(\s+)(\S+)/) {
// do nothing
} else {
$args .= " --rs $str";
}
Then I understood that it should have the not operator before it:
unless (! $args =~ /\-rs(\s+)(\S+)/ && ! $args =~ /\-p(\s+)(\S+)/ && !
+ $args =~ /\-P(\s+)(\S+)/) {
$args .= " --rs $str";
}
But it still does not work as expected. My last guess is due to regex grouping but not sure what to do. How to solve it?