Skip Menu |

This queue is for tickets about the Encode CPAN distribution.

Report information
The Basics
Id: 80181
Status: resolved
Priority: 0/
Queue: Encode

People
Owner: Nobody in particular
Requestors: DROLSKY [...] cpan.org
Cc:
AdminCc:

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



Subject: Uninitialized value warning from Encode->encodings()
The docs document this as a method call, but if you call it as a method with no additional arguments you get: Use of uninitialized value $_[1] in string eq at /home/autarch/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/x86_64- linux/Encode.pm line 65. The problem is this code: if ( @_ and $_[1] eq ":all" ) { ... } When called as a method, @_ is always true. The rest of the internals seem to suggest that you _don't_ expect this sub to be called as a method, since you access "@_" without shifting anything off. I think you really need to shift off the first argument like you were doing before, either that or document this as a backwards incompatible change and document calling this as a sub, not a method. But this seems like something that's not worth breaking back compat for.
Thank you. Fixed as follows. Dan the Maintainer Thereof --- Encode.pm 2012/08/15 05:36:16 2.47 +++ Encode.pm 2013/02/18 01:25:27 @@ -62,7 +62,8 @@ sub encodings { my %enc; - if ( @_ and $_[1] eq ":all" ) { + my ( $class, $arg ) = @_; + if ( $arg eq ":all" ) { %enc = ( %Encoding, %ExtModule ); } else { On Sun Oct 14 16:06:34 2012, DROLSKY wrote: Show quoted text
> The docs document this as a method call, but if you call it as a method > with no additional arguments you get: > > Use of uninitialized value $_[1] in string eq at > /home/autarch/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/x86_64- > linux/Encode.pm line 65. > > The problem is this code: > > if ( @_ and $_[1] eq ":all" ) { ... } > > When called as a method, @_ is always true. > > The rest of the internals seem to suggest that you _don't_ expect this > sub to be called as a method, since you access "@_" without shifting > anything off. > > I think you really need to shift off the first argument like you were > doing before, either that or document this as a backwards incompatible > change and document calling this as a sub, not a method. But this seems > like something that's not worth breaking back compat for.