Re: 2.055 POP3 Transport/POP3.pm bug
Mark Overmeer <[email protected]> Wed, 16 Jun 2004 10:55:06 +0200
| Newsgroups | gmane.comp.lang.perl.modules.mail-box |
|---|---|
| Organization | MARKOV Solutions |
| Message-ID | <[email protected]> |
* Jason Woodward ([email protected]) [040608 05:56]: > Using the following test script with a vanilla 2.055 install: > my $pop3 = $mgr->open( > type => 'pop3', > > throws up this error: > Can't call method "isModified" without a package or object reference at > /usr/local/share/perl/5.8.4/Mail/Box.pm line 434, <GEN1> line 122. Good catch! Everywhere else in that module, using $_ was protected, but not on that specific place. Usually very hard to find this kind of mistakes. > This is caused by a $_ scoping issue which seems to be fixed by the following patch: > ### begin patch > --- /usr/local/share/perl/5.8.4/Mail/Transport/POP3.pm 2004-06-07 23:51:19.000000000 -0400 > +++ /usr/local/share/perl/5.8.4/Mail/Transport/POP3.pm.new 2004-06-07 23:51:16.000000000 -0400 > @@ -366,10 +366,10 @@ sub status($;$) > if(OK($uidl)) > { my @n2uidl; > $n2uidl[$self->{MTP_messages}] = undef; # optimization, sets right size > - while(<$socket>) > - { last if substr($_, 0, 1) eq '.'; > - s#\r?\n$##; m#^(\d+) (.+)#; > - $n2uidl[$1] = $2; > + while( my $line = <$socket>) > + { last if substr($line, 0, 1) eq '.'; > + $line =~ s#\r?\n$##; $line =~ m#^(\d+) (.+)#; > + $n2uidl[$1] = $2 if ($1 && $2); > } > shift @n2uidl; # make message 1 into index 0 > $self->{MTP_n2uidl} = \@n2uidl; The best way to fix it is by adding a "local $_" before the while. So, I have changed this piece of code into local $_; # protect global $_ while(<$socket>) { last if substr($_, 0, 1) eq '.'; s#\r?\n$##; $n2uidl[$1] = $2 if m#^(\d+) (.+)#; } -- Thanks for the report! MarkOv ------------------------------------------------------------------------ drs Mark A.C.J. Overmeer MARKOV Solutions [email protected] [email protected] http://Mark.Overmeer.net http://solutions.overmeer.net