Tom Phoenix                                                   
             <[EMAIL PROTECTED]                                             
             om>                                                        To 
             Sent by:                  "[EMAIL PROTECTED]"            
             [EMAIL PROTECTED]         <[EMAIL PROTECTED]>            
             .com                                                       cc 
                                       beginners@perl.org                  
                                                                   Subject 
             01/25/2006 12:26          Re: use of uninitialized value....  
             PM                                                            
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           









> My problem seems to be within the Net::FTP module.  I have intentionally
> modified my password so that my error routines can be tested, but once
the
> login
> piece fails it continues on,  when I would expect that it should die at
the
> code in red.

I don't see any code in red.

> The uninitialized value is $OHMONSTER, but the FTP piece is
> not exiting.

> print "step 6 for loop\n";
>                 foreach ($ftp->ls()) {
>                     if (/${$fref}\d+\w+/)  {
>                        $OHMONSTER = $_;
>                        last;
>                     }
>                 }

If the test in the if statement never returns true, $OHMONSTER will
stay uninitialized. Is that the problem you're having? Check to see
whethere it's defined before you continue, if that matters. Hope this
helps!

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

Yes indeed the problme is within the OHMONSTER variable.  I determined this
through a print.
I was able to rid of the error and exit with a RC of zero when any part of
the Net::FTP failed by using a
return.  Here is what I did:

print "step 1 open log\n";
                open (FTPLOG, ">>$ftplog") || do {print FTPLOG "\ncould not
open file: $ftplog $!"};
print "step 2 init ftp\n";
                my $ftp = Net::FTP->new($remotehost, Debug => 10)
                || do {print FTPLOG "\nCannot connect to $remotehost: $!",
mailme(); return};
print "step 3 login\n";
               $ftp->login($user, $pass) || do {print FTPLOG "\nLogin
failed!: $!", mailme(); return};
print "step 4 print login failed then set bin\n";
                $ftp->binary();
print "step 5 cd directory\n";
                $ftp->cwd($remotedir) || do {print FTPLOG "\nCWD to folder
outbound failed!: $!", mailme(); return};
print "step 6 for loop\n";
                foreach ($ftp->ls()) {
                    if (/${$fref}\d+\w+/)  {
                       $OHMONSTER = $_;
                       last;
                    }
                    else {
                       print FTPLOG "\nFTP ls() or match failed...file will
not be renamed\n";
                       last;




-- 
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