In simple terms a perl object is nothing but a pointer to a normal perl data structure with some internal flag that elevates it to an object. (before anyone objects, yes, there is a bit more, especially a connection to a class).

Most of the time the normal data structure is a hash which doubles as data storage for the object. PerlMagick uses an array as basis of its object. And judging from the documentation, it can either store image data into this array, or recursively other image objects (at least that is my theory, can't test it as Image::Magick wouldn't install when I tried it a minute ago). You can see that in this snippet from an example in the PerlMagick documentation:

$p = $image->[1]; $p->Draw(stroke=>'red', primitive=>'rectangle', points=>20,20 100,10 +0');

One of the entries of the object array is taken and on this sub-object the Draw operation is called. To really be sure one would have to print ref($p) to see if it isn't a different object from ref($image), but it seems a neat way to allow the storage and manipulation of more than one image. Now a bit more clarity in the documentation would have been helpful


In reply to Re: advice on OO and perlmagick by jethro
in thread advice on OO and perlmagick by stabu

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.