http://qs321.pair.com?node_id=1105763


in reply to Re^4: Novice problem: How to push a MooX Struct into a list?
in thread Novice problem: How to push a MooX Struct into a list?

boftx was right and spotted the problem with argument passing to your printdirs sub. You also had a problem with the dereferencing syntax:

@($mydir->subdlist) should be @{$mydir->subdlist}

Also, while it's not an error, the check to see if the array is empty is redundant, the for loop wont run if there are zero elements in the array. So the sub could be rewritten as:

sub printdirs { my ($mydir) = @_; printdirs($_) for @{$mydir->subdlist}; print "Dir: ", $mydir->dirname, "\n"; }