[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Using Net::POP3



On Fri, 6 Nov 1998, Elton Hughes wrote:

> # Ambiguous use of {index} resolved to {"index"}.
> File 'Cyberia:Applications:MacPerl Ÿ:lib:Mac:InternetConfig.pm'; Line 501
> # Ambiguous use of {index} resolved to {"index"}.
> File 'Cyberia:Applications:MacPerl Ÿ:lib:Mac:InternetConfig.pm'; Line 503
> # Ambiguous use of {index} resolved to {"index"}.
> File 'Cyberia:Applications:MacPerl Ÿ:lib:Mac:InternetConfig.pm'; Line 509
> # Use of uninitialized value.
> File 'Cyberia:Applications:MacPerl Ÿ:lib:Mac:Types.pm'; Line 68
> # Use of uninitialized value.
> File 'Cyberia:Applications:MacPerl Ÿ:lib:Mac:Types.pm'; Line 68
> # can not authenticate: 
> # Use of uninitialized value during global destruction.
> 
  Most of these seem to be warnings generated by using anything that looks
at the Internet Config settings.  For example, I am using MailTools
(Mail::Mailer) and I get the following warnings when I send a message:

# Use of uninitialized value.
File 'MAIN SERVER:MacPerl f:site_perl:Mail:Mailer.pm'; Line 218
# Use of uninitialized value.
File 'MAIN SERVER:MacPerl f:site_perl:Mail:Mailer.pm'; Line 218
# Use of uninitialized value.
File 'MAIN SERVER:MacPerl f:site_perl:Mail:Mailer.pm'; Line 218
# Ambiguous use of {index} resolved to {"index"}.
File 'MAIN SERVER:MacPerl f:lib:Mac:InternetConfig.pm'; Line 501
# Ambiguous use of {index} resolved to {"index"}.
File 'MAIN SERVER:MacPerl f:lib:Mac:InternetConfig.pm'; Line 503
# Ambiguous use of {index} resolved to {"index"}.
File 'MAIN SERVER:MacPerl f:lib:Mac:InternetConfig.pm'; Line 509
# Use of uninitialized value.
File 'MAIN SERVER:MacPerl f:lib:Mac:Types.pm'; Line 68
# Use of uninitialized value.
File 'MAIN SERVER:MacPerl f:lib:Mac:Types.pm'; Line 68
# Use of uninitialized value.
File 'MAIN SERVER:MacPerl f:lib:Mac:Types.pm'; Line 56

  These seem to be rather harmless errors.  My code seems to work fine
(although some strange name lookup is happening, which may be related). 
That means that the first important warning is the 'can not authenticate".

  Actually, the code does authenticate fine.  The mistake is that the
functions don't return 0 and non-zero values for success and failure, they
return defined or undefined for success and failure.  I rewrote it a
little and here's what I came up with.  It ain't pretty, but it seems to
work....

====================
#!/usr/bin/perl -w

use Net::POP3;

$username = 'username';
$password = 'password';
$popserver = 'pop.server.org';

$pop = Net::POP3->new($popserver)
        or die "Can not open connection to $popserver : $!\n";

unless (defined $pop->login($username, $password))  {
        $pop->quit;
        die "Can not authenticate!\n";
}

unless (defined ($messages = $pop->list))  {
         $pop->quit;
         die "Can not get list of undeleted messages!\n";
}

$msgcount = scalar keys %$messages;

print "You have $msgcount messages.\n";

foreach $msgid (keys %$messages) {
        $message = $pop->get($msgid);
        unless (defined $message) {
                warn "could not fetch $msgid from server: $!\n";
                next;
        }
        # Do something with the message array here
}

$pop->quit;







***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch