Re: [rt-users] Match isWatcher and part of subjectline

2016-10-06 Thread Jeffrey Pilant
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. 

-
RT 4.4 and RTIR training sessions, and a new workshop day! 
https://bestpractical.com/training
* Boston - October 24-26
* Los Angeles - Q1 2017


Re: [rt-users] Match isWatcher and part of subjectline

2016-10-06 Thread Joel Bergmark
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)
{
return 0;
}
else {
return 1 if $self->TicketObj->IsWatcher(
Type => 'Requestor', Email => 'email-adr...@se.se'
);
return 0;
}

Regards,


Från: rt-users [mailto:rt-users-boun...@lists.bestpractical.com] För Joel 
Bergmark
Skickat: den 5 oktober 2016 15:25
Till: rt-users@lists.bestpractical.com
Ämne: [rt-users] Match isWatcher and part of subjectline

Anyone has some cool code to match something like this: If iswatcher is  then check if subject contains  return 1;  else return 0;

I cant get this simple stuff to work, perl isn't my thing :-)

Regards
-
RT 4.4 and RTIR training sessions, and a new workshop day! 
https://bestpractical.com/training
* Boston - October 24-26
* Los Angeles - Q1 2017

[rt-users] Match isWatcher and part of subjectline

2016-10-05 Thread Joel Bergmark
Anyone has some cool code to match something like this: If iswatcher is  then check if subject contains  return 1;  else return 0;

I cant get this simple stuff to work, perl isn't my thing :-)

Regards
-
RT 4.4 and RTIR training sessions, and a new workshop day! 
https://bestpractical.com/training
* Boston - October 24-26
* Los Angeles - Q1 2017