I'm having a problem with Class::MethodMaker object_list forwarded methods. Maybe I just can't get the syntax right. Can anyone can point me to a working code example or provide some insight? Or maybe ideas about peeking into the C::MM generated methods? My broken code and output follow the POD excerpt.

From POD:

object_list
Functions like list, but maintains an array of referenced objects in each slot. Forwarded methods return a list of the results returned by maping the method over each object in the array.
Arguments are like object.
use strict; use Class::MethodMaker "-sugar"; package MyPackage::Item; make methods new_hash_init => 'new', get_set => [qw/ name /], ; # make methods package MyPackage::List; make methods new_hash_init => 'new', object_list => [ MyPackage::Item => { slot => 'items', comp_mthds => [qw/ name /], }, ], ; package main; use Data::Dumper; my $list = MyPackage::List->new(); $list->items_push( MyPackage::Item->new(name=>'test1') ); print Dumper($list); # POD says this should return a list from a map # of the forwarded methods over all objects in # the list, but I can't get it to work! print $list->items->name;
Output:
$VAR1 = bless( { 'items' => [ bless( { 'name' => 'test1' }, 'MyPackage::Item' ) ] }, 'MyPackage::List' ); Can't call method "name" on unblessed reference at test.pl line 32.
--
The ability to destroy planets is insignificant next to the power of the Deacon Effect.


In reply to Class::MethodMaker object_list help needed by Solo

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.