in reply to Re^6: Ter::ANSIColor is awesome, but.. (need help)
in thread Term::ANSIColor is awesome, but.. (need help)
Why not implement that yourself?
package MyApp::User; use strict; use overload '""' => \&stringify, 'eq' => \&cmp, ; sub new { my( $class, %options )= @_; bless \%options => $class; }; sub stringify { my( $self )= @_; colorize( $self->{ name }, 'red' ); }; sub cmp { ... };
In the long run, this approach of adding more magic instead of cleanly separating display logic and business logic in your program will cause you lots of problems. Most likely you will encounter unintentional stringification. But that's an experience you'll have to make yourself.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Ter::ANSIColor is awesome, but.. (need help)
by mascip (Pilgrim) on Mar 30, 2014 at 16:17 UTC | |
by Corion (Patriarch) on Mar 30, 2014 at 16:24 UTC | |
by mascip (Pilgrim) on Mar 30, 2014 at 16:41 UTC | |
by Anonymous Monk on Mar 31, 2014 at 07:09 UTC | |
by mascip (Pilgrim) on Mar 31, 2014 at 14:30 UTC |