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
|