Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^5: Novice problem: How to push a MooX Struct into a list?

by Loops (Curate)
on Nov 01, 2014 at 00:06 UTC ( #1105763=note: print w/replies, xml ) Need Help??


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"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1105763]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2022-05-22 23:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (81 votes). Check out past polls.

    Notices?