Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble with GD

Status
Not open for further replies.

AMiSM

Technical User
Jan 26, 2006
128
0
0
US
I created an image object using GD. I am trying to use

$pic->rgb($pic->getPixel($ix,$iy))

inside a function.

It works fine outside of the function, but not inside the function. Is this out of scope?
 
It was inside an "if". I got it to work, but I'm curious if there is a limit to how deep into a number of nested blocks this call can be before it is out of scope. Is this ever an issue?
 
...what was inside an if?

if

Code:
sub block {
   my $img = something->new();
   if (1) {
      # $img should be in scope here still
   }
}

unless the thing was created inside an if block with "my" and went out of scope immediately after and then was used outside the if block.

On your last question though, there shouldn't be any issue of a number of nested blocks, as long as the variable they're using is in the same scope that their line of blocks also belongs to (and provided that variable wasn't overwritten by another local variable from the scope of another block between them). Perl won't even warn about if a block create a "my" variable with the same name as one in a higher scope (only if you do "my" twice in the same block for the same variable).

-------------
Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top