Nice one James - that does it ..!!

something more to learn - abs


many thanks..

-----Original Message-----
From: James Edward Gray II [mailto:[EMAIL PROTECTED]
Sent: 17 December 2003 17:35
To: Steve Massey
Cc: [EMAIL PROTECTED]
Subject: Re: Term:ANSIColor and negative numbers


On Dec 17, 2003, at 11:25 AM, Steve Massey wrote:

> Hi All
>
> using Term:ANSIColor - does anyone know if it's possible ( or maybe I 
> mean
> practical) to print out negative numbers in say RED, at the same time
> ensuring the original value is retained.
>
> so if value is -16 the it should print 16 in RED text otherwise leave 
> it
> alone.

Sure.

use Term::ANSIColor;

my $value = -16;

if ($value >= 0) { print "$value\n"; }
else { print colored(abs($value), 'red'), "\n"; }

Hope that helps.

James


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to