Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Error while taking 'Scalar of scalar'

by naikonta (Curate)
on Jul 04, 2007 at 12:14 UTC ( [id://624871]=note: print w/replies, xml ) Need Help??


in reply to Error while taking 'Scalar of scalar'

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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://624871]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-25 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found