The
coloring() subroutine returns a string (simple scalar) contains the color name, which you store in
$genecolor scalar variable. You pass in the
filledRectangle() method the
$$genecolor, which means you're trying to dereference
$genecolor. But
$genecolor is a simple scalar, not a reference, hence the error.
If you look up the perldiag, or in your local system, man perldiag or perldoc perldiag, you'll find the error explanation:
Can't use string ("%s") as %s ref while "strict refs" in use
(F) Only hard references are allowed by "strict refs". Symbolic ref
+erences are disallowed. See perlref.
If you put
use diagnostics; line near the top of your program, it will give you the error explanation automatically.
I don't know what the filledRectangle() method expects as the fifth argument. If it says a SCALAR reference or a reference to a SCALAR then you must pass it as:
$im->filledRectangle($X1,$Y1-20,$X2,$Y2,\$genecolor);
Otherwise, if it says nothing about references, then just pass in the variable as is:
$im->filledRectangle($X1,$Y1-20,$X2,$Y2,$genecolor);
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.