On Oct 30, 2001 at 11:01 +0530, Rajesh took the soap box and proclaimed: : Hi All, : I am trying to use an array of class::Struct as a member of : another Class::Struct. : This is something like a "array of strcutures within structure" in C. : The code is like: : : use Class::Struct; : : struct Employee => { : name => '$", : num => '$', : }; : : struct Dept => { : employees => '????' # should be array of Employee structs. But : dont know how to declare the array of class::struct Employee here. : no_of_emp => '$', : };
Remember that an object is just a scalar value. Therefore, if you want a list of scalar values, you just need an array. Here is an example: use Class::Struct; struct Employee => { name => '$', num => '$', }; struct Dept => { employees => '@', no_of_emp => '$', }; my @employees = ( Employee->new( name => 'Casey', num => 1 ), Employee->new( name => 'Kevin', num => 0 ), ); my $dept = Dept->new( employees => \@employees, no_of_emp => scalar @employees ); print $dept->employees->[0]->name, "\n"; Enjoy! Casey West -- "The wireless music box has no imaginable commercial value. Who would pay for a message sent to nobody in particular?" -- David Sarnoff's associates in response to his urgings for investment in the radio in the 1920s. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]