Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Ter::ANSIColor is awesome, but.. (need help)

by mascip (Pilgrim)
on Mar 30, 2014 at 14:13 UTC ( #1080292=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Ter::ANSIColor is awesome, but.. (need help)
in thread Term::ANSIColor is awesome, but.. (need help)

The starting point of my reasoning is:

There is only one place where I declare the variables that I want to colorize. If I could colorize them then and nowhere else, that would be much simpler.


Comment on Re^3: Ter::ANSIColor is awesome, but.. (need help)
Re^4: Ter::ANSIColor is awesome, but.. (need help)
by Corion (Pope) on Mar 30, 2014 at 14:15 UTC

    You will need to split up the two uses of $name, for internal program logic and for display.

      But this means passing around both variables everywhere, which is a pain.

      Oh! I just realized, I could I not notice? eq() is an operator, I can overload it! Time to Git clone and see if that works...

        I cannot overload eq() because Term::ANSIColor doesn't return an object. Ouch. Are there any alternative implementations out there that return an object?

        It could look like this:

        my $name = String::Colored->new('Jon', 'red'); # improvised module nam +e # Overloads stringification print $name; # Overloads string comparison operators my $res = $name eq 'Jon'; $name->stripcolor;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1080292]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2015-07-05 08:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls