[rt-users] Match isWatcher and part of subjectline

Jeffrey Pilant jeffrey.pilant at bayer.com
Thu Oct 6 15:50:26 EDT 2016


Joel Bergmark Writes:
>Could anyone assist with this scrip?
>
>This matches $match2 at every time, regardless if both $match1 and $match2 is 
>present in the subject-line. Hence the If(index part is not working, any good 
>perl-people that can correct it? Both matches must be present to not return 0;
>
>my $match1 = "InformationX";
>my $match2 = "[Y]";
>my $subject = $self->TicketObj->Subject;
>if (index(lc($subject), ($match1 && $match2)) eq -1)

The "&&" operator is a logical short-circuit AND.  If the first op ($match1) is false it returns false without evaluating the second op ($match2).
Neither $match1 nor $match2 is a logical, so it makes no sense.

Try this instead:
   if ((index(lc($subject), $match1) >= 0) && (index(lc($subject), $match2) >= 0))
reference:
   http://perldoc.perl.org/perlop.html#C-style-Logical-And
   http://perldoc.perl.org/functions/index.html

Another consideration: you are testing against a lower case version of the subject, yet both strings have upper case characters.  You will never find either string.

You need to AND the result of both index functions, to verify both are found.

/jeff

________________________________________________________________________
The information contained in this e-mail is for the exclusive use of the 
intended recipient(s) and may be confidential, proprietary, and/or 
legally privileged.  Inadvertent disclosure of this message does not 
constitute a waiver of any privilege.  If you receive this message in 
error, please do not directly or indirectly use, print, copy, forward,
or disclose any part of this message.  Please also delete this e-mail 
and all copies and notify the sender.  Thank you. 
________________________________________________________________________



More information about the rt-users mailing list