>
> the || do lines in the ftp section
> with a routine call to?  :
>
>     my $olddie = $SIG{__DIE__};
>     $SIG{__DIE__} = sub {
>         my $error = shift;
>         $olddie->{$error} if ref $olddie;
>         mailme($error);
>         #other error stuff here
>     };
>
snip

No, that defines the override of the default behavior of the die()
command (see perldoc -f die).  The "|| do { blah };" turns into "or
die 'message';"  You put all of the "blah" code in the override.

***********************************************************************************************************
***********************************************************************************************************

ok I read the perldoc and this seems to be the ideal way, but when any
condition fails, meaning
a connection fails, a login fails or a cwd fails I want to update the log
with the appropriate message for each failed
condition.  Using this ONE way your way will not do this for me instead I
will have to write THREE of these blocks  once for each failure...
UNLESS I can put an if in this routine like so:

     my $olddie = $SIG{__DIE__};
     $SIG{__DIE__} =

     sub {
         my $error = shift;
         $olddie->{$error} if ref $olddie;


         #other error stuff as below
          if ($RC == 0) {
              print FTPLOG message about connection
              mailme($error);
          }
          elif {
               ($RC == 1) {
               print FTPLOG message about login
               mailme($error);
          }
          else {
               ($RC == 2) {
               print FTPLOG message about cwd
               mailme($error);
     };

Here would be the ftp calls

my $ftp = Net::FTP->new($remotehost, Debug => 10) or
    die  "Cannot connect to $remotehost: $!", my $RC=0;

$ftp->login($user, $passs ) or die "Login failed $!", my $RC=1;

$ftp->cwd ($remotedir) or die "CWD failed $!", my $RC=2

Does this make sense logically?

thanks again,
derek


Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to