Hi, thanks for your reply. I succeeded with below.Now, it's OK.

$clean_total =~ s/^\s+|\s+$//g; $spam_total =~ s/^\s+|\s+$//g; $virus_total =~ s/^\s+|\s+$//g; $banned_total =~ s/^\s+|\s+$//g; $badheader_total =~ s/^\s+|\s+$//g; $reject_total =~ s/^\s+|\s+$//g;
Anyway, I checked with chomp($clean_total) as well. It also worked. Anyway, what is better? Here's my code

#!/usr/bin/perl use CGI; use CGI qw(:standard); use strict; use warnings; use GD; use GD::Graph; use GD::Graph::bars; use GD::Graph::Data; $ENV{"PATH"} = "/usr/sbin:/usr/bin:/sbin:/bin"; print "Content-type: text/html\n\n"; print "<body bgcolor=\"#95B8DB\">"; print "<br />"; print "<h1 align=center>\n"; print "Global Mail Statistics\n"; print "</h1>\n"; print "<br />"; print "<br />"; my $str = qx(date); print $str; print "<br />"; #Passed CLEAN - Clean Mails my $clean_total = qx(sudo grep -Ec 'amavis.*Passed CLEAN' /var/log/mai +llog); #chomp($clean_total); $clean_total =~ s/^\s+|\s+$//g; #Blocked SPAM - Spam Mails my $spam_total = qx(sudo grep -Ec 'amavis.*Blocked SPAM' /var/log/mail +log); #chomp($spam_total); $spam_total =~ s/^\s+|\s+$//g; #Blocked INFECTED - Virus Mails my $virus_total = qx(sudo grep -Ec 'amavis.*Blocked INFECTED' /var/log +/maillog); #chomp($virus_total); $virus_total =~ s/^\s+|\s+$//g; #Blocked BANNED - Banned Mails exe,scr etc. my $banned_total = qx(sudo grep -Ec 'amavis.*Blocked BANNED' /var/log/ +maillog); #chomp($banned_total); $banned_total =~ s/^\s+|\s+$//g; #BAD-HEADER- - Bad Header Mails my $badheader_total = qx(sudo grep -Ec 'amavis.*BAD-HEADER-' /var/log/ +maillog); #chomp($badheader_total); $badheader_total =~ s/^\s+|\s+$//g; #REJECT - REJECT Mails my $reject_total = qx(sudo grep -c 'reject' /var/log/maillog); #chomp($reject_total); $reject_total =~ s/^\s+|\s+$//g; print "<br />"; my $data = GD::Graph::Data->new([ ["Cleaned","Spam","Virus","Banned","BadHeader","Rejected"], [ $clean_total, $spam_total, $virus_total, $banned_to +tal, $badheader_total, $reject_total], ]) or die GD::Graph::Data->error; #my $data = GD::Graph::Data->new([ # ["Cleaned","Spam","Virus","Banned","BadHeader","Rejected"], # [10, 36, 0, 0, 0, 974], #]) or die GD::Graph::Data->error; my $graph = GD::Graph::bars->new(600,300); $graph->set( x_label => 'Category', y_label => 'Count', title => 'Global Mail Statistics', # Show values on top of each bar show_values => 1, #y_max_value => 7, y_tick_number => 8, #y_label_skip => 3, #x_labels_vertical => 1, #show_values => 1, #values_vertical => 1, #values_space=> 4, bar_spacing => 10, shadow_depth => -4, shadowclr => 'dred', transparent => 0, ) or die $graph->error; $graph->set_title_font("/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf",1 +4); $graph->set_x_axis_font("/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf", +8); $graph->set_y_axis_font("/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf", +8); $graph->set_x_label_font("/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf" +,12); $graph->set_y_label_font("/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf" +,12); $graph->plot($data) or die $graph->error; my $file = 'bars.png'; open(my $out, '>', "../../../tmp/$file") or die "Cannot open '$file' f +or write: $!"; binmode $out; print $out $graph->gd->png; close $out; system("sudo /bin/cp -pf /tmp/$file /var/www/html/"); print "<img src=../$file><p>\n"; print "<br />"; print "</body>"; print "</html>\n";

This works as expected. I would like to test your other perl code too.Since it is very very perl way. One more question is remaing. How can change font size of values on the top of the bar.


In reply to Re^4: problem with show_values => 1, while drawing a bar graph with variables by theravadamonk
in thread problem with show_values => 1, while drawing a bar graph with variables by theravadamonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.