in reply to Nested Class::Struct
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Nested Class::Struct
by a.kumaresh (Initiate) on Aug 29, 2010 at 04:40 UTC | |
by NetWallah (Canon) on Aug 29, 2010 at 07:18 UTC |