Sponsored Content
Full Discussion: color print using perl
Top Forums Shell Programming and Scripting color print using perl Post 302603396 by roopa on Thursday 1st of March 2012 12:38:57 AM
Old 03-01-2012
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
Code:
#!/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

Code:
#!/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
Code:
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

Moderator's Comments:
Mod Comment How to use code tags

Last edited by Franklin52; 03-01-2012 at 03:11 AM.. Reason: Please use code tags for code and data samples, thank you
 

4 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Print in color

I have a short code below: awk 'NR==1 {printf "'$information'-MYDATA-'$information' \n"} {print $0}' data.file > newdata.file I want the "information" color in RED and MYDATA in BLUE. How can I do it? Please help!!!! (3 Replies)
Discussion started by: bobo
3 Replies

2. Shell Programming and Scripting

how to get the Format header in perl in different color

Now here is the problem how to get the Format header in perl in different color. format RPT_TOP= DINISO EXECUTION REPORT @<<<<<<<<<<<<< AGAINST SEOPACTUAL Page : @>>> $TODAY,$%... (3 Replies)
Discussion started by: rrd1986
3 Replies

3. Shell Programming and Scripting

creating color palette using awk or perl

Hi, I'm wondering if anyone have tried creating a color palette or table using awk or perl using a range of values. thanks for any suggestion in advance. 0-0.1: purple 0.1-0.2: blue 0.2-0.3: green 0.3-0.4: yellow 0.4-0.5: orange > 0.5: red Happy holidays,:) (5 Replies)
Discussion started by: ida1215
5 Replies

4. AIX

How to print color text in AIX?

Hi I'd like to print color text and I've tried this: echo "\033but it didn't woked. When I changed 0 --> 1/4/5, the text "HI" --> bold/underline/blink, but when I changed 31 or 33 to other values, the color didn't change. What's the problem. Need to install something ??? (8 Replies)
Discussion started by: bobochacha29
8 Replies
set_color(1)							       fish							      set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 03:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy