Net::NNTP / Net::Cmd giving unpredicatable warnings 
Author Message
 Net::NNTP / Net::Cmd giving unpredicatable warnings

Hi,

I have the following code that checks for cancel messages in the groups
that I'm subscribed to and then posts a summary to an internal
newsgroup.

use strict;
use warnings;
use diagnostics;
use Net::NNTP;
use Config::IniFiles;

my $cfg = Config::IniFiles->new(-file => 'cancelcheck.ini');

#open (ARTNO,'last.cancel') || die "Can't open last.cancel $!";
#chomp(my $startno = <ARTNO>);
#close ARTNO;

my $startno = $cfg->val('Cancel','LastArtNo');

my $hamster;
if($hamster = Net::NNTP->new('localhost')){
        $hamster->authinfo('USER','PASS') || die "Can't authinticate";
        print "Connected to Hamster\n";

Quote:
}

$hamster->debug(1); # added in to find problem
my $cancelserver = Net::NNTP->new('news.lineone.net') || die "No
connection to cancel server";
$cancelserver->debug(1); # added in to find problem
open (STDERR,'>cancelcheck.err');# added in to find problem
print "Connected to lineone\n";
$cancelserver->group('control.cancel');
die "Can't change to control.cancel" unless ($cancelserver->ok);


my %checkmid;
my $timerequired = $cfg->val('Newnews','TimeSent');
$cfg->setval('Newnews','TimeSent',time);

        unless ($group =~ /^mailing-lists\./){
                $checkmid{$group} = $hamster->newnews($timerequired,$group);
        }

Quote:
}

print "Starting downloading cancels\n";

my $cancel = $cancelserver->xhdr('Control',"$startno-");


$cfg->setval('Cancel','LastArtNo',$sorted[$#sorted]);
$cfg->RewriteConfig;

print "Populating cancel hash\n\n";
foreach my $no (keys %$cancel){
        my $article = substr($$cancel{$no},7);
        $$cancel{$article}=$no;

Quote:
}

my %cancelled;

# %cancelled has the groups being checked as keys.
# each value corresponds to a cancelled article and
# is a hash with the key being the Message-ID.
# The values of that is an array with [0] being header info of the
# article and [1] being header info of the cancel.

# $cancelled{group}->{mid}->[Articel][Cancel];

print "Checking\n";
while(my ($group,$midlist) = each %checkmid){

                if (exists($$cancel{$mid})){
                        $cancelled{$group}->{$mid} = [$hamster-

Quote:
>head($mid),$cancelserver->head($$cancel{$mid})];

                }
        }
Quote:
}

$hamster->post;
$hamster->datasend("Newsgroups: internal.misc\n");
$hamster->datasend("From: Cancel Check

my $date = (localtime)[3] . '-' . ((localtime)[4] +1)  . '-' .
((localtime)[5] +1900);

$hamster->datasend("Subject: Cancel Report for $date \n\n");
$hamster->datasend("The following articles were found to be
cancelled\n\n");

foreach my $group (sort keys %cancelled){
        $hamster->datasend("$group\n");
        $hamster->datasend('=' x length($group), "\n\n");
        foreach my $mid (keys %{$cancelled{$group}}){
                $hamster->datasend("\t$mid\n\n");

Quote:
>{$mid}->[0]};

                $hamster->datasend("\n\twas cancelled by\n\n");

Quote:
>{$mid}->[1]};

                $hamster->datasend("\n");
        }
Quote:
}

$hamster->dataend;

Sometimes this works fine but about 1 night in 4 I get warnings like:

Use of uninitialized value in substr at C:/perl/site/lib/Net/Cmd.pm
line 307 (#1)
    (W uninitialized) An undefined value was used as if it were already
    defined.  It was interpreted as a "" or a 0, but maybe it was a
mistake.
    To suppress this warning assign a defined value to your variables.

    To help you figure out what was undefined, perl tells you what
operation
    you used the undefined value in.  Note, however, that perl
optimizes your
    program and the operation displayed in the warning may not
necessarily
    appear literally in your program.  For example, "that $foo" is
    usually optimized into "that " . $foo, and the warning will refer
to
    the concatenation (.) operator, even though there is no . in your
    program.

Argument "" isn't numeric in numeric eq (==) at
C:/perl/site/lib/Net/NNTP.pm
        line 624 (#2)
    (W numeric) The indicated string was fed as an argument to an
operator
    that expected a numeric value instead.  If you're fortunate the
message
    will identify which operator was so unfortunate.

followed by

Argument "" isn't numeric in numeric eq (==) at
C:/perl/site/lib/Net/Cmd.pm
        line 425 (#2)

and no message posted to the newsgroup.

To try and get to the bottom of this I turned on the debugging and sent
STDERR to a text file and then waited for the error.

Below is a shortened version of the error file (I've removed most
things that look OK to me). The full version can be found at
http://www.*-*-*.com/ ~graham.drabble/net::nntp-errors.txt.

0x1fc0edc is the conversation with $cancelserver
0x1fc35ec is the conversation with $hamster

Net::NNTP=GLOB(0x1fc0edc)>>> GROUP control.cancel

Net::NNTP=GLOB(0x1fc0edc)<<< 211 128392 28965669 29094063
control.cancel selected
Net::NNTP=GLOB(0x1fc35ec)>>> LIST

Net::NNTP=GLOB(0x1fc35ec)<<< 215 list of newsgroups follows
Net::NNTP=GLOB(0x1fc35ec)>>> NEWNEWS news.groups.questions 020804
220040 GMT

Net::NNTP=GLOB(0x1fc35ec)<<< 230 New news follows
Net::NNTP=GLOB(0x1fc35ec)>>> NEWNEWS gweep.software.announce 020804
220040 GMT

Net::NNTP=GLOB(0x1fc35ec)<<< 230 New news follows
Net::NNTP=GLOB(0x1fc35ec)>>> NEWNEWS comp.lang.perl.misc 020804 220040
GMT

<snip>

Net::NNTP=GLOB(0x1fc35ec)>>> NEWNEWS visi.help 020804 220040 GMT

Net::NNTP=GLOB(0x1fc35ec)<<< 230 New news follows
Net::NNTP=GLOB(0x1fc35ec)>>> NEWNEWS uk.rec.scouting 020804 220040 GMT

Net::NNTP=GLOB(0x1fc35ec)<<< 230 New news follows
Net::NNTP=GLOB(0x1fc35ec): Timeout at cancelcheck.pl line 33
Net::NNTP=GLOB(0x1fc35ec)>>> NEWNEWS news.software.nntp 020804 220040
GMT


Use of uninitialized value in substr at C:/perl/site/lib/Net/Cmd.pm
line 307 (#1)
    (W uninitialized) An undefined value was used as if it were already
    defined.  It was interpreted as a "" or a 0, but maybe it was a
mistake.
    To suppress this warning assign a defined value to your variables.

    To help you figure out what was undefined, perl tells you what
operation
    you used the undefined value in.  Note, however, that perl
optimizes your
    program and the operation displayed in the warning may not
necessarily
    appear literally in your program.  For example, "that $foo" is
    usually optimized into "that " . $foo, and the warning will refer
to
    the concatenation (.) operator, even though there is no . in your
    program.

Argument "" isn't numeric in numeric eq (==) at
C:/perl/site/lib/Net/NNTP.pm
        line 624 (#2)
    (W numeric) The indicated string was fed as an argument to an
operator
    that expected a numeric value instead.  If you're fortunate the
message
    will identify which operator was so unfortunate.

Net::NNTP=GLOB(0x1fc35ec)>>> NEWNEWS visi.stats 020804 220040 GMT


Net::NNTP=GLOB(0x1fc35ec)>>> NEWNEWS internal.newgroup 020804 220040
GMT


Net::NNTP=GLOB(0x1fc35ec)>>> NEWNEWS news.admin.announce 020804 220040
GMT

<snip - carries on returning MID rather than 230 ...>

Net::NNTP=GLOB(0x1fc35ec)>>> NEWNEWS uk.rec.motorcycles 020804 220040
GMT


Net::NNTP=GLOB(0x1fc0edc)>>> XHDR Control -

Net::NNTP=GLOB(0x1fc0edc)<<< 221 Control fields follow
substr outside of string at cancelcheck.pl line 56 (#3)
    (W substr),(F) You tried to reference a substr() that pointed
outside of
    a string.  That is, the absolute value of the offset was larger
than the
    length of the string.  See perlfunc/substr.  This warning is fatal
if
    substr is used in an lvalue context (as the left hand side of an
    assignment or as a subroutine argument for example).

Use of uninitialized value in hash element at cancelcheck.pl line 58
(#1)


Argument "" isn't numeric in numeric eq (==) at
C:/perl/site/lib/Net/NNTP.pm
        line 617 (#2)
Net::NNTP=GLOB(0x1fc0edc)>>> HEAD 29052448

Net::NNTP=GLOB(0x1fc0edc)<<< 221 29052448

follows
Net::NNTP=GLOB(0x1fc35ec)>>> POST


Argument "" isn't numeric in numeric eq (==) at
C:/perl/site/lib/Net/NNTP.pm
        line 626 (#2)
Net::NNTP=GLOB(0x1fc35ec)>>> Newsgroups: internal.misc
Net::NNTP=GLOB(0x1fc35ec)>>> From: Cancel Check

Net::NNTP=GLOB(0x1fc35ec)>>> Subject: Cancel Report for 5-8-2002
Net::NNTP=GLOB(0x1fc35ec)>>> The following articles were found to be
cancelled
Net::NNTP=GLOB(0x1fc35ec)>>> comp.lang.perl.misc
Net::NNTP=GLOB(0x1fc35ec)>>> ===================

Net::NNTP=GLOB(0x1fc35ec)>>>
Net::NNTP=GLOB(0x1fc35ec)>>>   was cancelled by
Net::NNTP=GLOB(0x1fc35ec)>>>           From: "John W. Krahn"

Net::NNTP=GLOB(0x1fc35ec)>>>           X-Mailer: Mozilla 4.79 [en] (X11;
U; Linux 2.4.4-4GB i586)
Net::NNTP=GLOB(0x1fc35ec)>>>           X-Accept-Language: en
Net::NNTP=GLOB(0x1fc35ec)>>>           MIME-Version: 1.0
Net::NNTP=GLOB(0x1fc35ec)>>>           Newsgroups: comp.lang.perl.misc
Net::NNTP=GLOB(0x1fc35ec)>>>           Subject: cancel

Net::NNTP=GLOB(0x1fc35ec)>>>           References:

Net::NNTP=GLOB(0x1fc35ec)>>>           Control: cancel

Net::NNTP=GLOB(0x1fc35ec)>>>           Content-Type: text/plain;
charset=us-ascii
Net::NNTP=GLOB(0x1fc35ec)>>>           Content-Transfer-Encoding: 7bit
Net::NNTP=GLOB(0x1fc35ec)>>>           Lines: 1
Net::NNTP=GLOB(0x1fc35ec)>>>           Message-ID:

Net::NNTP=GLOB(0x1fc35ec)>>>           Date: Mon, 05 Aug 2002 17:34:31
GMT
Net::NNTP=GLOB(0x1fc35ec)>>>           NNTP-Posting-Host: 66.183.114.153
Net::NNTP=GLOB(0x1fc35ec)>>>           X-Trace: news2.telusplanet.net
1028568871 66.183.114.153 (Mon, 05 Aug 2002 11:34:31 MDT)
Net::NNTP=GLOB(0x1fc35ec)>>>           NNTP-Posting-Date: Mon, 05 Aug
2002 11:34:31 MDT
Net::NNTP=GLOB(0x1fc35ec)>>>           Path: mk-nntp-
1.news.uk.worldonline.com!kibo.news.demon.net!demon!logbridge.uoregon.e
du!newsfeed.stanford.edu!cyclone.bc.net!newsfeed.telusplanet.net!news2.
telusplanet.net.POSTED!53ab2750!not-for-mail
Net::NNTP=GLOB(0x1fc35ec)>>>           Xref: mk-nntp-
1.news.uk.worldonline.com control.cancel:29052448
Net::NNTP=GLOB(0x1fc35ec)>>>
Net::NNTP=GLOB(0x1fc35ec)>>> .

Argument "" isn't numeric in numeric eq (==) at
C:/perl/site/lib/Net/Cmd.pm
        line 425 (#2)
Net::NNTP=GLOB(0x1fc35ec)>>> QUIT


Argument "" isn't numeric in numeric eq (==) at
C:/perl/site/lib/Net/NNTP.pm
        line 627 (#2)
Net::NNTP=GLOB(0x1fc0edc)>>> QUIT

Net::NNTP=GLOB(0x1fc0edc)<<< 205 closing connection - goodbye!

Any clues as to how to make this more reliable would be very gratefully
received.

--
Graham Drabble
If you're interested in what goes on in other groups or want to find
an interesting group to read then check news.groups.reviews for what
others have to say or contribute a review for others to read.



Sat, 22 Jan 2005 06:46:54 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Using Net:CMD method for Net:FTP

2. Net::FTP.pm Net::Cmd.pm question

3. Net::SMTP and Net::Cmd datasend() problem

4. Bug in Net::FTP sub _extract_path (or Net::Cmd sub parse_response)

5. reading messages through Net::FTP and/or Net::Cmd

6. Net::FTP.pm Net::Cmd.pm question

7. Net::SMTP and Net::Cmd datasend() problem

8. Problems compiling/installing Net-ext-0.91 (Net::Gen, Net::UDP etc)

9. NET::SSH, NET::FTP, NET::POP3 (how to detect)

10. Net::Telnet->cmd + > 256 chars

11. keep getting time out on Net::Telnet->cmd in my perl script

12. Net:SSH - Permission problem with ssh->cmd...

 

 
Powered by phpBB® Forum Software