|Pathologically Eclectic Rubbish Lister|
Term::ANSIColor is awesome, but.. (need help)by mascip (Pilgrim)
|on Mar 30, 2014 at 13:17 UTC||Need Help??|
mascip has asked for the
wisdom of the Perl Monks concerning the following question:
Hi there :-)
I've just used Term::ANSIColor in an app for the first time, and found it really awesome. I didn't have to change anything at all in my code: I just declared the colors on some variables.
and almost all the rest worked as if nothing had been changed, but now my terminal outputs are much more readable.
My problem starts when some commands do string comparison:
This breaks because $name is not just Jon now, it's red Jon.
One workaraound is to use colorstrip():
That works, but it means I have to make this change everywhere in the code, which is a pain. Especially when these variables get sent to various objects who do all the hard work.
Is there any way to make this work? Some way of saying: "You're being compared? Wait, I'll colorstrip you first".
If that was included in the Term::ANSIColor module, that would be even better. That's why I just wrote to the module author, to come and read this message.
Any idea how to take advantage of Perl's flexibility and perform this trick?