in reply to Re: Nested Class::Struct
in thread Nested Class::Struct

thanks :) that worked. I was trying to use push and friends. like this push @{Dad->children}, child_t_new();Resulted in undefined object method children error.

Replies are listed 'Best First'.
Re^3: Nested Class::Struct
by NetWallah (Canon) on Aug 29, 2010 at 07:18 UTC
    Well - that is the more perlish approach to adding elements to the array.
    This works:
    push @{ $Dad->children }, new child_t(type=>"Flower Child");
    This is closer to the syntax you were attempting (also works):
    push @{ $Dad->children }, child_t::new('child_t','type',"Wild Child") +;
    However, as others have pointed out, Class::Struct is a stepping stone into OO perl programming.
    I abandoned it fairly soon after learning the many more powerful constructs in OO perl.

    I'm still learning (after using perl for 8 years), and heading towards Moose (Which is sort of built-in to perl6).

    Update: The second example above is unnatural - here is a better way:

    push @{ $Dad->children }, child_t->new(type=>"Natural Child");

         Syntactic sugar causes cancer of the semicolon.        --Alan Perlis