color print using perl

Hi
i want to print the text in different color using perl script.
i am able to print on console(terminal).
but if i try to print the same into a file, i am not able to do
color.pl

#!/bin/usr/perl
use Term::ANSIColor;
print "This text is normal.\n";
use Term::ANSIColor qw(:constants);
$Term::ANSIColor::AUTORESET = 1;
print BOLD BLUE "This text is in bold blue.\n";
print "This text is normal.\n"; 

if try the following

#!/bin/usr/perl
use Term::ANSIColor;
open (OUT,">cl.txt"); 
print OUT "This text is normal.\n";
use Term::ANSIColor qw(:constants);
$Term::ANSIColor::AUTORESET = 1;
print OUT BOLD BLUE "This text is in bold blue.\n";
print OUT "This text is normal.\n"; 
close(OUT);

vi cl.txt

This text is normal.
^[[1m^[[34mThis text is in bold blue.
^[[0m^[[0mThis text is normal.

i am not getting output in color inside the file cl.txt

thanks
roopa

Obviously, in a text editor you'll see the raw formatting code that make text bold and beautiful.
Try cat c1.txt and you'll see what you want.

Is there any way to get color print inside text editor?

That's not the way a text editor (vi or emacs) works or may be I'm not aware.

  1. Ok, tell me this: if you want you want to manually change the formatting codes (say, change colour from blue to green) by yourself instead of a perl program doing it, how will you achieve this task?
  2. Why do you need to see coloured text in an editor? Rather, you could familiarise yourself with the formatting codes.
  3. What is the exact requirement?