in reply to Net::FTP server errors?

Have a look in perlvar for the variables $!, $?, $@ and $^E. They are conveniently grouped together under the label "Error Indicators".

$! is probably of most use to you:

$ftp->get("/that/camel/off/my/back") or die "Blerch: $!\n";

CU
Robartes-

Replies are listed 'Best First'.
Re: Re: Net::FTP server errors?
by Mr. Muskrat (Canon) on Oct 31, 2002 at 19:41 UTC

    Get is the only command that will return useful information in $!. If the file doesn't exist, it would print "Bad file descriptor at filename line x." to STDERR.

      Oops!

      my $ftp = Net::FTP->new("some.host.name") or die $!; would print "Invalid argument at filename line x." to STDERR.

        The fact that in this particular case $! contains something that might look like the right error message doesn't mean the other procedures will be able to use it as well.

        The list of errors that can be found in $! is fixed (and OS dependant). You can find out what it is by

        $lastmsg='noNSensE'; $i = 0; $! = $i; while ($lastmsg ne $!) { $lastmsg = ''.$!; print "$i: $!\n"; $i++; $! = $i; }

        Try also:

        $! = "Hello world"; print "$!\n";

        So as you see it is possible to change the $!, but you can't give a very specific error message.

        What GhodMode wants is

        $ftp->message()

        Of course that doesn't work for the "new Net::FTP", but that was not requested.

        Jenda