[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Some help needed with object oriented perl!



I was wondering if someone could give some help
on passing variables by reference.  My specific need
is with the GD graphics programming.

Some background: An image is created with this line:
    $im = new GD::Image(200, 200);
I would like to write a subroutine that takes the reference
to the object ($im in this case), and some arguments,
then do the necessary drawing. After the subroutine call,
$im object will have been updated.

For example, if I write a subroutine to draw a five pointed
star, how do I reference $im in the subroutine?  I read
some documentation from www.perl.com and I am more
confused than ever!

I know that \$im is a reference to the variable $im, but
I understand that in my example, $im is a pointer to an object
of type GD::Image!


Code fragments:

$im = new GD::Image(200, 200);
&drawstar($im, 100, 100, 20);
# output the $im to file

sub drawstar {
  my ($im, $x, $y, $d) = @_;    # <- is this line correct?
# draw a star using graphics primitives on $im
  return;
}


Thank you,
Charles Cave
charles@irg.com.au

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org