1838955 Members
3577 Online
110132 Solutions
New Discussion

Re: Perl Help

 
SOLVED
Go to solution
Ragni Singh
Super Advisor

Perl Help

Can anyone tell me what I'm doing wrong with this script..

What is wrong with my syntax error.What I am doing in removing those 2 names from teh distribution list and adding my name to it. Also, when I print my name, I am only getting "schand.com" and it seems to be omitting "@pacificex". POints will be assigned.

458 if($sth->execute){
459 my $ntuples = $sth->rows;
460 if ($ntuples > 0) {
461 for ( my $i=0; $i < $ntuples; $i++) {
462 @row = $sth->fetchrow; # Get a row
463 $row[0] = &clip($row[0]);
464 if ($row[0] != "parmstrong@pacificex.com") || ($row[0] != "bburke@pacificex.com") {
465 $distList .= "$row[0]; ";
466 }
467 }
468 }
469 }else{ # PGRES_TUPLES_OK is not OKAY
470 die "Execution Error, Possible Parse error in field. Check your input
$DBI::errst";
471 }
472 $distList .= "schand@pacificex.com";
473 }


syntax error at secdaily.test line 464, near ") ||"
syntax error at secdaily.test line 469, near "}else"
8 REPLIES 8
Alexander Chuzhoy
Honored Contributor

Re: Perl Help

For start add backslash \ before each @ sign.
What errors have you left with now?
Bill Thorsteinson
Honored Contributor
Solution

Re: Perl Help

You need to escape the @ character.
Otherwise perl tries to acces the array
@pacificex.

Try using
$distList .= "schand\@pacificex.com";
Ragni Singh
Super Advisor

Re: Perl Help

Thanks Bill, if I want to add multiple people to the distList, what would my syntax be on this line...

$distList .="schand\@pacificex.com"

I want to add john, jon to this list

Thanks and I will give points in the end.
Ralph Grothe
Honored Contributor

Re: Perl Help

I would think it's easier to use an array instead of a scalar, and push the other recipients on the array.

push @distList, qw(john@johns.com harry@harrys.org);

or if the recipients all have the same MX,
and you want to stick to the scalar

$dom = 'our.org';
$distList = join(' ',map $_.'@'.$dom, qw(john harry));

Madness, thy name is system administration
Ragni Singh
Super Advisor

Re: Perl Help

I am not a perl person so I don't understand what you mean by that. I just want to make this as simple as possible. In the dislist line, whats is the syntaxt to add multiple e-mail addresses.
Sergejs Svitnevs
Honored Contributor

Re: Perl Help

You need to change string 464:

from:
if ($row[0] != "parmstrong@pacificex.com") || ($row[0] != "bburke@pacificex.com") {

to:
if ( ($aaa != "parmstrong\@pacificex.com") || ($aaa != "bburke\@pacificex.com") ) {


Regards,
Sergejs
Sergejs Svitnevs
Honored Contributor

Re: Perl Help

Oooops, sorry.

You need to change string 464:

from:
if ($row[0] != "parmstrong@pacificex.com") || ($row[0] != "bburke@pacificex.com") {

to:
if ( ($row[0] != "parmstrong\@pacificex.com") || ($row[0] != "bburke\@pacificex.com") ) {


Regards,
Sergejs
Sheldon Smith
HPE Pro

Re: Perl Help

First, you need an outer set of parentheses around the entire IF expression:
if ( ($row[0] != "parmstrong@pacificex.com") || ($row[0] != "bburke@pacificex.com") ) {

It does not matter, it will not work anyway. "!=" is a NUMERIC comparison. Both "parmstrong@pacificex.com" and "bburke@pacificex.com" evaluate to 1.
Use "ne" for string comparisons.

Note: While I am an HPE Employee, all of my comments (whether noted or not), are my own and are not any official representation of the company

Accept or Kudo