I am trying to read information from a file and generate a graph. When I run it in the browser, the image section shows up as a bunch of symbols and trash. I can't seem to pin point the problem.
#!/usr/bin/perl -w # # Retrieve form selections & display the results # use strict; use File::Find; use CGI; my $q = new CGI; use GD::Graph::points; my $request = $ENV{"Query String"}; # Assign input to variables my $start_month= $q->param('month'); my $start_day= $q->param('day'); my $start_year= $q->param('year'); my $start_hour= $q->param('hour'); my $start_min= $q->param('min'); my $test_site= $q->param('center'); print $q->header("text/html\n\n"), $q->start_html(-title=>"Data Report"), "Report for $center from $start_hour:$start_min $start_month/$star +t_day/$start_year.\n"; #Find the file (yymmdd_site format) undef$/; find (sub { return if($_ =~ /^\./); return unless($_ =~ /\.txt/i); stat $Find::File::name; return if -d; return unless -r; open(FILE, "<$Find::file::name") or return; my $headercount = 1; my $discard = <FILE > for 1 .. headercount; While(<FILE>){ chomp; my ($timestamp, $out, $in) = (split m{"\t"}) [0, 3, 7]); my @data = (["timestamp", "$timestamp"), [$out, $in]); my $mygraph = GD::Graph::points->new(500,300); $mygraph->set( x_label => 'Time/Date', y_label => 'COunt', ) or warn $mygraph-> error; my $myimage = $mygraph->plot(\@data) or die $mygraph->error; print "Content-type: image/png\n\n"; print $myimage->png; close(FILE); }, '/(name of my directory tree)' $q->end_html;

In reply to my image is not showing by ITmajor

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.