Skip Menu |

This queue is for tickets about the XML-Twig CPAN distribution.

Report information
The Basics
Id: 67632
Status: rejected
Priority: 0/
Queue: XML-Twig

People
Owner: Nobody in particular
Requestors: jim.king [...] simplivt.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Uninitialized value $nb in sub child (Twig.pm)
Date: Wed, 20 Apr 2011 16:10:23 -0400
To: bug-XML-Twig [...] rt.cpan.org
From: Jim King <jim.king [...] simplivt.com>
I've been seeing this warning over the last few weeks while using XML::Twig (v3.34): Use of uninitialized value $nb in numeric ge (>=) at /usr/share/perl5/XML/Twig.pm line 6146. Use of uninitialized value $nb in foreach loop entry at /usr/share/perl5/XML/Twig.pm line 6148. The code here is: sub child { my $elt= shift; my $nb= shift; if( $nb >= 0) # line 6146 I put a fix in place for this which may just be a band-aid: sub child { my $elt= shift; my $nb= shift; * if (!defined($nb)) { $nb = 0; } * if( $nb >= 0) My assumption is that if the caller did not set $nb then they meant zero. The same thing happens with XML::Twig v3.38: Use of uninitialized value $nb in numeric ge (>=) at /usr/local/share/perl/5.10.1/XML/Twig.pm line 6369. Use of uninitialized value $nb in foreach loop entry at /usr/local/share/perl/5.10.1/XML/Twig.pm line 6371. Here is an example of how I am processing the file: # this only returns the English version right now sub printError { my $self = shift; my $errnum = shift; my $errfile = "$ENV{'SVTBUILD'}/errors.xml"; my $twig = XML::Twig->new(); $twig->parsefile($errfile); my $root = $twig->root; if ($root->tag ne "Errors") { print "Unable to parse error file $errfile\n"; exit 1; } my $lookfor = "error.$errnum"; foreach my $description ($root->children('description')) { my $fn = $description->att('type'); if ($fn eq $lookfor) { foreach my $message ($description->children('message')) { my $lang = $message->att('lang'); my $module = 'task'; my $text = $message->child_text(); if ($lang eq 'en') { print "ERROR: $text\n"; return; } } } } print "Unknown error (in printError)\n"; } Here are the contents of the file: <?xml version="1.0"?> <Errors> <base>com.simplivt.task</base> <!-- define the valid task error descriptions and localize them --> <!-- these become com.simplivt.task.error.nnnn resources --> <description type="error.1013"> <message lang="en">Invalid name.</message> </description> </Errors> -- Jim King SimpliVT Corporation 8 Technology Drive, 2nd Floor Westborough, MA 01581-1756 (508) 373-7258
Subject: Re: [rt.cpan.org #67632] Uninitialized value $nb in sub child (Twig.pm)
Date: Thu, 21 Apr 2011 19:17:40 +0200
To: bug-XML-Twig [...] rt.cpan.org
From: Michel Rodriguez <xmltwig [...] gmail.com>
Actually, if the caller did not set $nb, it is probably an error, as the interface for child is specifically child( $offset, $optional_condition). It looks like the problem is with the line my $text   = $message->child_text();, which should be my $text= $message->text; (the message element doesn't have any children). Does this help? -- mirod On Wed, Apr 20, 2011 at 10:10 PM, Jim King via RT <bug-XML-Twig@rt.cpan.org> wrote: Show quoted text
> Wed Apr 20 16:10:44 2011: Request 67632 was acted upon. > Transaction: Ticket created by jim.king@simplivt.com >       Queue: XML-Twig >     Subject: Uninitialized value $nb in sub child (Twig.pm) >   Broken in: (no value) >    Severity: (no value) >       Owner: Nobody >  Requestors: jim.king@simplivt.com >      Status: new >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=67632 > > > > I've been seeing this warning over the last few weeks while using XML::Twig > (v3.34): > > Use of uninitialized value $nb in numeric ge (>=) at > /usr/share/perl5/XML/Twig.pm line 6146. > Use of uninitialized value $nb in foreach loop entry at > /usr/share/perl5/XML/Twig.pm line 6148. > > The code here is: > > sub child >  { my $elt= shift; >    my $nb= shift; >    if( $nb >= 0)                    # line 6146 > > I put a fix in place for this which may just be a band-aid: > > sub child >  { my $elt= shift; >    my $nb= shift; > *    if (!defined($nb)) >    { >        $nb = 0; >    } > *    if( $nb >= 0) > > My assumption is that if the caller did not set $nb then they meant zero. > > The same thing happens with XML::Twig v3.38: > > Use of uninitialized value $nb in numeric ge (>=) at > /usr/local/share/perl/5.10.1/XML/Twig.pm line 6369. > Use of uninitialized value $nb in foreach loop entry at > /usr/local/share/perl/5.10.1/XML/Twig.pm line 6371. > > Here is an example of how I am processing the file: > > # this only returns the English version right now > sub printError > { >    my $self = shift; >    my $errnum = shift; >    my $errfile = "$ENV{'SVTBUILD'}/errors.xml"; > >    my $twig = XML::Twig->new(); >    $twig->parsefile($errfile); >    my $root = $twig->root; > >    if ($root->tag ne "Errors") >    { >        print "Unable to parse error file $errfile\n"; >        exit 1; >    } > >    my $lookfor = "error.$errnum"; >    foreach my $description ($root->children('description')) >    { >        my $fn = $description->att('type'); >        if ($fn eq $lookfor) >        { >            foreach my $message ($description->children('message')) >            { >                my $lang   = $message->att('lang'); >                my $module = 'task'; >                my $text   = $message->child_text(); > >                if ($lang eq 'en') >                { >                    print "ERROR: $text\n"; >                    return; >                } >            } >        } >    } > >    print "Unknown error (in printError)\n"; > } > > Here are the contents of the file: > > <?xml version="1.0"?> > <Errors> >    <base>com.simplivt.task</base> > >    <!-- define the valid task error descriptions and localize them --> >    <!-- these become com.simplivt.task.error.nnnn resources --> > >    <description type="error.1013"> >        <message lang="en">Invalid name.</message> >    </description> > </Errors> > > -- > Jim King > SimpliVT Corporation > 8 Technology Drive, 2nd Floor > Westborough, MA 01581-1756 > (508) 373-7258
Subject: Re: [rt.cpan.org #67632] Uninitialized value $nb in sub child (Twig.pm)
Date: Thu, 21 Apr 2011 13:39:58 -0400
To: bug-XML-Twig [...] rt.cpan.org
From: Jim King <jim.king [...] simplivt.com>
Any idea on version 3.34 where this might be? I did not see it in Twig.pm. On Thu, Apr 21, 2011 at 1:17 PM, xmltwig@gmail.com via RT < bug-XML-Twig@rt.cpan.org> wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=67632 > > > Actually, if the caller did not set $nb, it is probably an error, as > the interface for child is specifically child( $offset, > $optional_condition). > > It looks like the problem is with the line my $text = > $message->child_text();, which should be my $text= $message->text; > (the message element doesn't have any children). > > Does this help? > > -- > mirod > > > > On Wed, Apr 20, 2011 at 10:10 PM, Jim King via RT > <bug-XML-Twig@rt.cpan.org> wrote:
> > Wed Apr 20 16:10:44 2011: Request 67632 was acted upon. > > Transaction: Ticket created by jim.king@simplivt.com > > Queue: XML-Twig > > Subject: Uninitialized value $nb in sub child (Twig.pm) > > Broken in: (no value) > > Severity: (no value) > > Owner: Nobody > > Requestors: jim.king@simplivt.com > > Status: new > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=67632 > > > > > > > I've been seeing this warning over the last few weeks while using
> XML::Twig
> > (v3.34): > > > > Use of uninitialized value $nb in numeric ge (>=) at > > /usr/share/perl5/XML/Twig.pm line 6146. > > Use of uninitialized value $nb in foreach loop entry at > > /usr/share/perl5/XML/Twig.pm line 6148. > > > > The code here is: > > > > sub child > > { my $elt= shift; > > my $nb= shift; > > if( $nb >= 0) # line 6146 > > > > I put a fix in place for this which may just be a band-aid: > > > > sub child > > { my $elt= shift; > > my $nb= shift; > > * if (!defined($nb)) > > { > > $nb = 0; > > } > > * if( $nb >= 0) > > > > My assumption is that if the caller did not set $nb then they meant zero. > > > > The same thing happens with XML::Twig v3.38: > > > > Use of uninitialized value $nb in numeric ge (>=) at > > /usr/local/share/perl/5.10.1/XML/Twig.pm line 6369. > > Use of uninitialized value $nb in foreach loop entry at > > /usr/local/share/perl/5.10.1/XML/Twig.pm line 6371. > > > > Here is an example of how I am processing the file: > > > > # this only returns the English version right now > > sub printError > > { > > my $self = shift; > > my $errnum = shift; > > my $errfile = "$ENV{'SVTBUILD'}/errors.xml"; > > > > my $twig = XML::Twig->new(); > > $twig->parsefile($errfile); > > my $root = $twig->root; > > > > if ($root->tag ne "Errors") > > { > > print "Unable to parse error file $errfile\n"; > > exit 1; > > } > > > > my $lookfor = "error.$errnum"; > > foreach my $description ($root->children('description')) > > { > > my $fn = $description->att('type'); > > if ($fn eq $lookfor) > > { > > foreach my $message ($description->children('message')) > > { > > my $lang = $message->att('lang'); > > my $module = 'task'; > > my $text = $message->child_text(); > > > > if ($lang eq 'en') > > { > > print "ERROR: $text\n"; > > return; > > } > > } > > } > > } > > > > print "Unknown error (in printError)\n"; > > } > > > > Here are the contents of the file: > > > > <?xml version="1.0"?> > > <Errors> > > <base>com.simplivt.task</base> > > > > <!-- define the valid task error descriptions and localize them --> > > <!-- these become com.simplivt.task.error.nnnn resources --> > > > > <description type="error.1013"> > > <message lang="en">Invalid name.</message> > > </description> > > </Errors> > >
>
Subject: Re: [rt.cpan.org #67632] Uninitialized value $nb in sub child (Twig.pm)
Date: Tue, 17 May 2011 16:49:35 -0400
To: bug-XML-Twig [...] rt.cpan.org
From: Jim King <jim.king [...] simplivt.com>
I see now, the "my" confused me - when I read it the first time I expected to find that in Twig.pm, not in my code. This fixed my issue - thanks. On Thu, Apr 21, 2011 at 1:17 PM, xmltwig@gmail.com via RT < bug-XML-Twig@rt.cpan.org> wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=67632 > > > Actually, if the caller did not set $nb, it is probably an error, as > the interface for child is specifically child( $offset, > $optional_condition). > > It looks like the problem is with the line my $text = > $message->child_text();, which should be my $text= $message->text; > (the message element doesn't have any children). > > Does this help? > > -- > mirod > > > > On Wed, Apr 20, 2011 at 10:10 PM, Jim King via RT > <bug-XML-Twig@rt.cpan.org> wrote:
> > Wed Apr 20 16:10:44 2011: Request 67632 was acted upon. > > Transaction: Ticket created by jim.king@simplivt.com > > Queue: XML-Twig > > Subject: Uninitialized value $nb in sub child (Twig.pm) > > Broken in: (no value) > > Severity: (no value) > > Owner: Nobody > > Requestors: jim.king@simplivt.com > > Status: new > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=67632 > > > > > > > I've been seeing this warning over the last few weeks while using
> XML::Twig
> > (v3.34): > > > > Use of uninitialized value $nb in numeric ge (>=) at > > /usr/share/perl5/XML/Twig.pm line 6146. > > Use of uninitialized value $nb in foreach loop entry at > > /usr/share/perl5/XML/Twig.pm line 6148. > > > > The code here is: > > > > sub child > > { my $elt= shift; > > my $nb= shift; > > if( $nb >= 0) # line 6146 > > > > I put a fix in place for this which may just be a band-aid: > > > > sub child > > { my $elt= shift; > > my $nb= shift; > > * if (!defined($nb)) > > { > > $nb = 0; > > } > > * if( $nb >= 0) > > > > My assumption is that if the caller did not set $nb then they meant zero. > > > > The same thing happens with XML::Twig v3.38: > > > > Use of uninitialized value $nb in numeric ge (>=) at > > /usr/local/share/perl/5.10.1/XML/Twig.pm line 6369. > > Use of uninitialized value $nb in foreach loop entry at > > /usr/local/share/perl/5.10.1/XML/Twig.pm line 6371. > > > > Here is an example of how I am processing the file: > > > > # this only returns the English version right now > > sub printError > > { > > my $self = shift; > > my $errnum = shift; > > my $errfile = "$ENV{'SVTBUILD'}/errors.xml"; > > > > my $twig = XML::Twig->new(); > > $twig->parsefile($errfile); > > my $root = $twig->root; > > > > if ($root->tag ne "Errors") > > { > > print "Unable to parse error file $errfile\n"; > > exit 1; > > } > > > > my $lookfor = "error.$errnum"; > > foreach my $description ($root->children('description')) > > { > > my $fn = $description->att('type'); > > if ($fn eq $lookfor) > > { > > foreach my $message ($description->children('message')) > > { > > my $lang = $message->att('lang'); > > my $module = 'task'; > > my $text = $message->child_text(); > > > > if ($lang eq 'en') > > { > > print "ERROR: $text\n"; > > return; > > } > > } > > } > > } > > > > print "Unknown error (in printError)\n"; > > } > > > > Here are the contents of the file: > > > > <?xml version="1.0"?> > > <Errors> > > <base>com.simplivt.task</base> > > > > <!-- define the valid task error descriptions and localize them --> > > <!-- these become com.simplivt.task.error.nnnn resources --> > > > > <description type="error.1013"> > > <message lang="en">Invalid name.</message> > > </description> > > </Errors> > > > > -- > > Jim King > > SimpliVT Corporation > > 8 Technology Drive, 2nd Floor > > Westborough, MA 01581-1756 > > (508) 373-7258
> >
-- Jim King SimpliVT Corporation 8 Technology Drive, 2nd Floor Westborough, MA 01581-1756 (508) 373-7258