469,312 Members | 2,493 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,312 developers. It's quick & easy.

File output using colour

Hi Experts,

I am interested in creating some Report files for that using below lines of perl
code to display out put in colour to distinguish different types of Errors

use Term::ANSIColor;
print color .........etc


similary is there any possibility to dump the content to a file in UNIX platform using PERL so that when it is opened it should display information in colours

Thanks & Regards
Sarma
Apr 12 '07 #1
8 5408
tifoso
41
Why not print to an html file that way the coloring is straighforward

#...
print "<html><body>..."; etc
...
print "<font color=-red> Massive ERROR</font>";
....

if the perl is run from a web-page you can pop-up a page
with your results, don't forget to add
print "Content-type: text/html \n\n";
at the top

Ciao
Apr 12 '07 #2
KevinADC
4,059 Expert 2GB
Hi Experts,

I am interested in creating some Report files for that using below lines of perl
code to display out put in colour to distinguish different types of Errors

use Term::ANSIColor;
print color .........etc


similary is there any possibility to dump the content to a file in UNIX platform using PERL so that when it is opened it should display information in colours

Thanks & Regards
Sarma
You would have to decide what type of UNIX file format to use that understands color and write the file in that format so when it's opened the application that reads the file knows how to display the embedded markup instructions. Decide on a file format and search CPAN to see if there is a perl module that writes files in that format you decide to use.
Apr 12 '07 #3
Hi Kevin,

how to use the CPAN modules the reason is some time back i wanted to create and dump data to excel sheet instead of normal UNIX file so i gone through the help information on how to use the CPAN modeules in the net but when i download i realize i don't have permissions to add that module to the perl installer so regarding this also this will not help me

except this CPAN can u suggest me some other simple approach to dump into the file which i can open using vim or vi editors


Best Regards
Kiran Kumar
Apr 13 '07 #4
KevinADC
4,059 Expert 2GB
Do you know how to print anything to a file? Thats all you need to do, then open the file with what ever editor you want. But you said you wanted colorized output. For that you have to know how to write the color information into the file. I don't know how off the top of my head. And it depends on the file format you will be using. If it's just plain text you can't include color information or any other stuff besides spaces, tabs, or newlines.
Apr 13 '07 #5
miller
1,089 Expert 1GB
Hello Kiran Kumar,

The best advice that I can give you is to not try to do this.

If you want to create reports that differentiate between different levels of errors, then give those errors different labels. For example the Apache::Log module has 8 sequential log levels: emerg, alert, crit, error, warn, notice, info, debug. It is possible to set the current log level of the server so that logs of a certain less critical level are not recorded. And in the log file, all messages of a specific type are prefixed with that type label.

It is true that you can create pretty colours, but this requires specific knowledge on how to read them. It is a much better practice to stick with a standard file format such as plain text or html as new people will know how to read it. Besides, having color implies that you'll have to have some type of legend to translate what it means, where as having a label makes it more inherantly obvious.

That's all my advice concerning this subject,
- Miller
Apr 13 '07 #6
KevinADC
4,059 Expert 2GB
That's all my advice concerning this subject,
- Miller


heheheh.... you sound like Forrest Gump ;)
Apr 13 '07 #7
miller
1,089 Expert 1GB
heheheh.... you sound like Forrest Gump ;)
hehe :)

Yeah, at one time (almost 7 years ago) I also looked into adding colour to some of my terminal scripts. I eventually figured out why this is a foolhardy thing to do. There are much better methods for making reporting easy on the eyes. Preferably ones that are less prone to errors of their own.

- M
Apr 13 '07 #8
Miller,
Thanks for your suggestion coming to this i am new to CPAN related stuff but anyway i got there is tar.gz kit available to install it , is it ok if i install only in local directory/path or has to be installed in root directrory where entire perl package installed , if it needs 2nd option then i don't have previliges so it will stop me using this package

the reason i asked colour dump into ASCII file is to distinguish various statements not only for displaying error data (let us say if it is not an error or warning from any output but wanted to distinguish the output information dumped into a normal ASCII file to be opened by vi editors based on some catogery )

It is great help if you can provide help information on installation or the link where can i get suc info
Thanks
Kiran
Apr 17 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Herman | last post: by
7 posts views Thread by Krista Bailie | last post: by
3 posts views Thread by Andreas Palsgård | last post: by
3 posts views Thread by ryanbreakspear | last post: by
7 posts views Thread by B. Williams | last post: by
9 posts views Thread by colin | last post: by
41 posts views Thread by biplab | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.