use strict; use Class::Struct; struct child_t => { type => '$', }; struct parent_t => { type => '$', child => 'child_t', children=>'@', }; #--- For a single child ---- my $Dad = new parent_t(child=> new child_t(type=>"teenager")); print $Dad->child->type() . "\n"; #------ To use Multiple Children --- my $index=0; for (2..6){ $Dad->children($index++, new child_t(type=>"Type $_")); } for (@{ $Dad->children() }){ print "Kid type " . $_->type() . "\n"; }
Syntactic sugar causes cancer of the semicolon. --Alan Perlis
In reply to Re: Nested Class::Struct
by NetWallah
in thread Nested Class::Struct
by a.kumaresh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |