webalizer是一個簡單易用的日志分析軟件,但安裝好中文版本後,出來的圖表中總有讓人心煩的亂碼。本文用一個簡單的perl處理腳本就可讓亂碼不再出現。 #!/usr/bin/perl $file_graph = "$ARGV[0]/graphs.c"; if(!(-e $file_graph)) { print "error open $file_graph "; print "Usage: perl $0 DIR "; #DIR是源文件目錄,比如 ./ exit; } #把圖表中的月份和注釋改成英文 @old_var = ("msg_h_hits", "msg_h_pages", "msg_h_visits", "msg_h_files", "msg_h_sites", "msg_h_xfer", "s_month"); @new_var = ("msg_gh_hits", "msg_gh_pages", "msg_gh_visits", "msg_gh_files", "msg_gh_sites", "msg_gh_xfer", "s_gmonth"); open(IN,"$file_graph"); for($i=0;$i$file_lang"); print OUT QQ~ /* --- start Add ---*/ char *msg_gh_hits = "Hits"; char *msg_gh_pages = "Pages"; char *msg_gh_visits= "Visits"; char *msg_gh_files = "Files"; char *msg_gh_sites = "Sites"; char *msg_gh_xfer = "KBytes"; char *s_gmonth[12]={ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; /* -------------End------------- */ ~; #補充聲明這些新加的函數 print " patch $ARGV[0]/lang.h "; $file_lang = "$ARGV[0]/lang.h"; open(OUT,">>$file_lang"); print OUT qq~ /* --- start Add ---*/ extern char *msg_gh_hits ; extern char *msg_gh_pages ; extern char *msg_gh_visits; extern char *msg_gh_files ; extern char *msg_gh_sites ; extern char *msg_gh_xfer ; extern char *s_gmonth[12]; /* -------------End------------- */ ~; print "Done ^_^ "; ############################################################