Subject: | Encode::Alias::find_alias fails if invoked as a function |
See also the discussion on Stackoverflow:
http://stackoverflow.com/questions/9956198/
The version of Encode::Alias on my system is 2.15.
The problem is in:
# Public, encouraged API is exported by default
our @EXPORT =
qw (
define_alias
find_alias
);
our @Alias; # ordered matching list
our %Alias; # cached known aliases
sub find_alias {
require Encode;
my $class = shift;
my $find = shift;
unless ( exists $Alias{$find} ) {
find_alias does not take into account the possibility that it may be
invoked as a function rather than a class method.
A solution is to check if @_ == 1, and accordingly. Or, one can do
something cute like:
sub find_alias {
require Encode;
my $find = pop;
my $class = pop || __PACKAGE__;
...