Subject: | Array Ref issue in sub colored |
The sub "colored" does only check if the passed parameter is a
reference, but not if it's indeed an array refence.
227 sub colored {
228 my ($string, @codes);
229 if (ref $_[0]) {
I think this should definitely be fixed. See the following script example.
$ cat foo.pl
#!/usr/bin/perl
use Term::ANSIColor;
print colored("ok\n", 'bold blue');
$foo = Foo->new();
print colored($foo . "", 'bold blue'); # stringify applies
print colored($foo, 'bold blue'); # perl error
package Foo;
use overload '""' => 'stringify';
sub new {
$self = {};
bless( $self );
}
sub stringify {
return "Foo Bar\n";
}
$ perl foo.pl
ok
Foo Bar
Not an ARRAY reference at /usr/local/share/perl/5.10.1/Term/ANSIColor.pm
line 230.
$
In my case it's a serious problem because I use Term::ANSIColor with
Log::Log4Perl::Appender and DBIx::Class. In case of SQL error
DBIx::Class passes a blessed reference into the ->log method o which
then is passed tsub colored.