Class::Struct - want to access structure within structure
am 29.04.2006 21:33:33 von nelson331I want to access a structure within a structure. Below is what I had
in mind. Please help.
#!/perl/bin/perl
use Class::Struct;
struct Step => {
number => '$',
otherstuff => '$',
};
struct Block => {
number => '$',
steps => '@', #should be an array of "Step"s
};
my $step1 = Step->new();
$step1->number(1);
my $step2 = Step->new();
$step2->number(2);
#will eventually be in side a loop @stepArray = (@stepArray,
$tempStep);
@stepArray = ($step1, $step2);
my $block1 = Block->new();
$block1->number(1);
$block1->steps(@stepArray); #this isn't working
@blockArray = (@blockArray, $block1);
#would then like to access the Steps within the Blocks
foreach $tempBlock (@blockArray) {
foreach $tempStep ($tempBlock->steps) { #
print $tempStep->number;
}
}