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

Re: [MacPerl] nntp



At 10:44 AM -0500 on 12/19/96, Paul J. Schinder wrote:


}
}Your script fails under Unix Perl 5.003 as well with the same error
}message.  The problem is that Net::NNTP uses timegm but doesn't use
}Time::Local, where timegm is defined.  The error message you see is Perl's
}last desperate attempt to find timegm.  The fix is to simply place use
}Time::Local after use Net::Cmd (line 390) in NNTP.pm.  But now the Unix
}version returns -1.  (I can't check it with MacPerl right now.)  This is a
}problem with the regular expression on line 861 (line number *after* adding
}in use Time::Local) in sub date.  Change the (\d{4}) to \d\d(\d\d), and
}then things work just fine.  I've notified Graham Barr about the bugs, and
}I'll update the MacPerl ready libnet soon.

Oops.  While the change in the regexp fixes things under Unix Perl, with
its effective range of years from 1970-2038, it doesn't under MacPerl,
where there can be two valid years ending in 05, etc.  So here's how I've
fixed sub date:

sub date
{
 @_ == 1 or croak 'usage: $nntp->date()';
 my $nntp = shift;

 $nntp->_DATE && $nntp->message =~ /(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/
    ? timegm($6,$5,$4,$3,$2-1,$1-1900)
    : undef;
}

}
}This bring up a question, which I'll look into shortly.  ->date is
}documented to return seconds past the Unix zero of time.  Because you're
}using Time::Local under MacPerl, you get the number of seconds past the Mac
}zero of time, which is different.  I'll have to check the RFC for NNTP and
}see if the Unix zero of time is required.  If so, another change will be
}necessary.

After some time spent at the Internic Web site, I still don't know the
answer for sure, but I think it's "no".  The server I tried returns the
date as a yyyymmddhhmmss string.  In any event the DATE command isn't
defined in RFC 977, so it must be a later addition, for which I've yet to
find an RFC.  So I'll just let  Net::NNTP->date return seconds past Jan 1
1904 on a Mac, as Net::Time->inet_time already does.  Both
libnet-1.01.sit.hqx and libwww-perl-5.05.sit.hqx on mors.gsfc.nasa.gov have
been updated with the fixed NNTP.pm.


--------
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693
Greenbelt, MD 20770
schinder@pjstoaster.pg.md.us