Oh yes, I just need a very thin wrapper. I should stop working on the weekend: I'm too tired to think. I imagined I'd have to refactor Term::ANSIColor into a class.
It could look like this instead (more generic):
package String::Colored;
sub new {
my( $class, $string, $color )= @_;
bless { string => $string, color => $color } => $class;
};
sub stringify {
my( $self )= @_;
colored( $self->{ name }, $self->{$color} );
}
sub eq {
...
}
I like the idea.
But I read your advice and now I'm wondering.
Do you think you could give me the simplest example of how I might encounter unintentional stringification?
I'm heading back home, I'll think about this tonight.