Help with scrip

Hi,

I have different scrips that check for certain words in the subject line
and the code looks for example like that:

if ($self->TransactionObj->Type eq “Create” &&
$self->TicketObj->Subject =~ /[A|a]kut: / )
–snip–

so, if the subject contains “akut” do something.
That works.

What I now want to do is, if the subject contains not “akut” or
“project” than do that…

my code looks like this:

if ($self->TransactionObj->Type eq “Create” &&
$self->TicketObj->Subject !=~ /[P|p]roje[c|k]t: / ||
$self->TicketObj->Subject !=~/[A|a]kut: / )
–snip–

and that doesn’t work. I am not an perl expert, maybe someone can tell
me where my thinkingproblem is?

Thanks in advance
Violetta

________________________________ creating IT solutions
Violetta J. Wawryk science + computing ag
IT-Service Hagellocher Weg 73
phone +49 7071 9457 282 72070 Tuebingen, Germany
fax +49 7071 9457 211 www.science-computing.de
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Florian Geyer,
Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Prof. Dr. Hanns Ruder
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196

my code looks like this:

if ($self->TransactionObj->Type eq “Create” &&
$self->TicketObj->Subject !=~ /[P|p]roje[c|k]t: / ||
$self->TicketObj->Subject !=~/[A|a]kut: / )
–snip–

sorry, for bothering you. it actually works, the problem was something
else in my code which prevented my scrip to run through.

Bye
Violetta
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Florian Geyer,
Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Prof. Dr. Hanns Ruder
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196

Actually I think you should put the || phrase in parentheses like so:

if ($self->TransactionObj->Type eq “Create” &&
($self->TicketObj->Subject !=~ /[P|p]roje[c|k]t: / ||
$self->TicketObj->Subject !=~/[A|a]kut: / ) )

I’m pretty sure that && is a higher precedence than ||, so the result
without parentheses would be the same as ( ( A && B ) || C ) instead of ( A
&& ( B || C )) which is what you described.

At 08:31 AM 10/16/2008, Violetta Wawryk wrote:

my code looks like this:

if ($self->TransactionObj->Type eq “Create” &&
$self->TicketObj->Subject !=~ /[P|p]roje[c|k]t: / ||
$self->TicketObj->Subject !=~/[A|a]kut: / )
–snip–

sorry, for bothering you. it actually works, the problem was something
else in my code which prevented my scrip to run through.

Bye
Violetta

Gene LeDuc, GSEC
Security Analyst
San Diego State University

Hi Rene,

brauch mal dringend hilfe vom perlguru. ich möchte was abfrage und zwar
wenn ich im subject akut nicht drinnen steht dann solls zutreffen

$self->TicketObj->Subject !=~ /[A|a]kut: / --> tut nicht
$self->TicketObj->Subject !~ /[A|a]kut: / --> tut nicht

wie muss das denn richtig heissen wenn ich negieren will?

$self->TicketObj->Subject =~ /[A|a]kut: / --> das tut wenns zutrifft

Danke
Violetta

Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Florian Geyer,
Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Prof. Dr. Hanns Ruder
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196

sorry, the german mail was not meant for the mailinglist args
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Florian Geyer,
Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Prof. Dr. Hanns Ruder
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196

Hi,

if ($self->TransactionObj->Type eq “Create” &&
($self->TicketObj->Subject !=~ /[P|p]roje[c|k]t: / ||
$self->TicketObj->Subject !=~/[A|a]kut: / ) )

I’m pretty sure that && is a higher precedence than ||, so the result
without parentheses would be the same as ( ( A && B ) || C ) instead of
( A && ( B || C )) which is what you described.

I understand that now. Thank you. But I found out my scrip is not
working because of the wrong regex.

$self->TicketObj->Subject !=~ /[A|a]kut: / → doesn’t work
$self->TicketObj->Subject !~ /[A|a]kut: / → doesn’t work

what would be the right expression to make it negative?

$self->TicketObj->Subject =~ /[A|a]kut: / → does work for positiv

Thanks
Violetta
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Florian Geyer,
Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Prof. Dr. Hanns Ruder
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196

Hi Violetta,

Try this:

if ( $self->TransactionObj->Type eq “Create” &&
! ( $self->TicketObj->Subject =~ /proje[c|k]t: /i ||
$self->TicketObj->Subject =~ /akut: /i ) )

Regards,
Gene

At 02:59 AM 10/17/2008, Violetta Wawryk wrote:

Hi,

if ($self->TransactionObj->Type eq “Create” &&
($self->TicketObj->Subject !=~ /[P|p]roje[c|k]t: / ||
$self->TicketObj->Subject !=~/[A|a]kut: / ) )

I’m pretty sure that && is a higher precedence than ||, so the result
without parentheses would be the same as ( ( A && B ) || C ) instead of
( A && ( B || C )) which is what you described.

I understand that now. Thank you. But I found out my scrip is not working
because of the wrong regex.

$self->TicketObj->Subject !=~ /[A|a]kut: / → doesn’t work
$self->TicketObj->Subject !~ /[A|a]kut: / → doesn’t work

what would be the right expression to make it negative?

$self->TicketObj->Subject =~ /[A|a]kut: / → does work for positiv

Thanks
Violetta

Gene LeDuc, GSEC
Security Analyst
San Diego State University

Hi Gene,

good idea, thanks. But didn’t work either. The scip is than always
applicable and always applies the customfield which it should not do. args

I also tried unless, but than I get the errormessage:

Scrip 17 IsApplicable failed: syntax error at (eval 950) line 1, near
“->Subject unless”

So I guess this strange perl doesn’t know unless.

Somehow I cannot believe that noone ever tried something like this.

Frustated Greetings
Violetta

Gene LeDuc schrieb:

Hi Violetta,

Try this:

if ( $self->TransactionObj->Type eq “Create” &&
! ( $self->TicketObj->Subject =~ /proje[c|k]t: /i ||
$self->TicketObj->Subject =~ /akut: /i ) )

Regards,
Gene

Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Florian Geyer,
Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Prof. Dr. Hanns Ruder
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196

Violetta,

I missed this thread. What are you trying to do?

Kenn
LBNLOn 10/19/2008 11:53 PM, Violetta Wawryk wrote:

Hi Gene,

good idea, thanks. But didn’t work either. The scip is than always
applicable and always applies the customfield which it should not do. args

I also tried unless, but than I get the errormessage:

Scrip 17 IsApplicable failed: syntax error at (eval 950) line 1, near
“->Subject unless”

So I guess this strange perl doesn’t know unless.

Somehow I cannot believe that noone ever tried something like this.

Frustated Greetings
Violetta

Gene LeDuc schrieb:

Hi Violetta,

Try this:

if ( $self->TransactionObj->Type eq “Create” &&
! ( $self->TicketObj->Subject =~ /proje[c|k]t: /i ||
$self->TicketObj->Subject =~ /akut: /i ) )

Regards,
Gene

Hi Violetta,

I’ve been on vacation so I didn’t see your message until today. I’m
confused by your mail because there was no “unless” clause in any of the
code that I saw or suggested. The snippet you included doesn’t have one
either - it’s a simple “if” conditional:
if ( A && ! (B || C) ) {
do_this;
and_this;
}

Where is the “unless” clause coming from?

Gene

At 11:53 PM 10/19/2008, Violetta Wawryk wrote: