I got some code that looks exactly like this:

my $dbps = DBI->connect($dsn, 'root', 'password'); my $pgprep = $dbps->prepare('SELECT * FROM polls'); $pgprep->execute(); while (my $ref = $pgprep->fetchrow_hashref()) { my @labels = split(/#NEXT#/, $ref->{'choice'}); my @values = split(/#/, $ref->{'votes'}); my @data = (\@labels, \@values); open (TST, ">testtt.txt"); print TST $#values; print TST "\n".$#labels; close (TST); my $graph = new GD::Graph::bars3d(300,300); $graph->set( x_label => 'Poll Choices', y_label => 'Votes', title => $ref->{'title'}, dclrs => [ qw(orange blue green) ], borderclrs => [ qw(orange) ], x_labels_vertical => 1, labelclr => $param{'labelClr'}, axislabelclr => $param{'axisClr'}, textclr => $param{'titleClr'}, cycle_clrs => 1 ); $graph->set_title_font($param{'fontPath'}.$param{'titleFont'}.' +.ttf', $param{'titleSize'}); $graph->set_x_label_font($param{'fontPath'}.$param{'xLabelFont' +}.'.ttf', $param{'xLabelSize'}); $graph->set_x_axis_font($param{'fontPath'}.$param{'xAxisFont'}. +'.ttf', $param{'xAxisSize'}); $graph->set_y_label_font($param{'fontPath'}.$param{'yLabelFont' +}.'.ttf', $param{'yLabelSize'}); $graph->set_y_axis_font($param{'fontPath'}.$param{'yAxisFont'}. +'.ttf', $param{'yAxisSize'}); open (PNG, '>'.$param{'apacheRoot'}.$param{'graphImg'}.$ref->{' +id'}.'.png'); binmode PNG; print PNG $graph->plot(\@data)->png; #THis is where the eval e +rror is. close (PNG); print '<br>&nbsp;'; print '<table cellpadding=2 cellspacing=0 align="center" style= +"border: 0px; width: 88%;">'; print '<tr><td style="color: #3FBFE9; font-weight: bold;" style +="background-image: url(/jpg/layout/redback.jpg);" align="center">'.$ +ref->{'title'}.'</td></tr>'; print '<tr><td style="border: 1px solid #810306;" align="center +">'; print '<img src="'.$param{'absURI'}.$ref->{'id'}.'.png">'; print '</td></tr>'; print '</table>'; }


This code works fine when it's in it's own script, but when i put it inside an eval() function it crashes where i print it to the PNG file ($graph->plot(\@data)->png;).

I know the code is sloppy and what not, but I just want to get it to work first. Is this an issue with my code or the eval() function. Thanks for taking your time to help me.

janitored by ybiC: Obscured db root password as courtesy to posting monk


In reply to eval() issues. by Mercio

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.