Keep It Simple, Stupid | |
PerlMonks |
Term::ANSIColor - possible to pass color as variable?by ultranerds (Hermit) |
on Apr 13, 2011 at 12:54 UTC ( [id://899178]=perlquestion: print w/replies, xml ) | Need Help?? |
ultranerds has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I'm trying to write a simple debug function, which will let me pass in a string + a color (or color combination). This is what I have so far: ..which is called with: print_debug ("foo","blue"); However, I would prefer to be able to simply pass in stuff like: print_debug ("foo","blue on_white"); ...which would convert to: print BLUE ON_WHITE, "foo", RESET; This doesn't seem to be valid syntax though: I'm guessing its cos the $color is actually a variable. Is there a way I can do this, or should I just stick with my other solution? TIA Andy
Back to
Seekers of Perl Wisdom
|
|