Well I am have finally got the code to recognized the right substring but
not the issue is my if statement.  Could someone see what I am doing
wrong,please.

For example I ran the script and got the following output:

E:\sea621\siebsrvr\BIN\perl\bin>perl emailmgr.pl
Successfully Completed Email Manager Working Sleeping for 10

It should have sent the email but did not..

#/usr/bin/perl

$cmd = '..\\..\\srvrmgr /g apollo.ts.checkpoint.com /e CHK_ENT_PRD /s
CHK_SBL_PRD /u xxxxxxxx /p xxxxxx /c "list tasks for server CHK_SBL_PRD
component Email Manager" > ..\\..\\emailmgr.txt';
$result = `$cmd`;                       # note back-ticks

#open a file with the filehandle
open EMAILMGR, "+<..\\..\\emailmgr.txt"  or die "Cannot open email manager
$!\n";

#my $data = <EMAILMGR> for (1..22);      #Testing to make sure I am
#grabbing the correct data----
for(my $i=0; $i<22; $i++){<EMAILMGR>};   #This will put you at row 23.----
  $_=<EMAILMGR>;
  my $line=$_;

if (substr($line, 105, 16) eq "Sleeping for 10")
{

  use Mail::Sendmail;                    #Send and email if there are errors
  %mail = ( To      =>  '[EMAIL PROTECTED]',
            From    =>  '[EMAIL PROTECTED]',
            Subject =>  '',
            Message =>   'Email Manager: '.substr($line, 112, 10),
           );
  sendmail(%mail) or die $Mail::Sendmail::error;
  print "OK. Log says:\n", $Mail::Sendmail::log;

}
else
{
        print "Successfully Completed Email Manager Working";
        print  substr($line, 105, 16);
}

-----Original Message-----
From: John W. Krahn [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 23, 2002 4:17 PM
To: [EMAIL PROTECTED]
Subject: Re: subsrting question

Lance Prais wrote:
>
> I am trying to use the substr() to search a text doc.   The starting place
> is 100.

If you want to _search_ for a string you should be using index(),
rindex() or a regular expression.


> I am trying to test to see if   "Sleeping for 10"  is there.
>
> This is the code I am trying to use substr($line 100,16)  but is only
                                                  ^
                                             missing comma

> returning "Sleeping f"
>
> What could I be doing wrong?

Could there be control characters or non-ASCII characters in there
somewhere?



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to