Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Build tree data structure from DB (flat) data; function golf

by NamfFohyr (Scribe)
on Aug 30, 2006 at 17:50 UTC ( #570438=note: print w/ replies, xml ) Need Help??


in reply to Build tree data structure from DB (flat) data; function golf

Disclaimer: noobish advice

I don't understand why it concerns you that the foreach pushes to an array. It's scoped within the subroutine so I don't think it's particularly inefficient.

Because you push twice to the output array, a map is difficult to pull off while preserving the overall flow of information. This probably occcurred to you.

The remaining duplicated code seems natural to me to leave as-is. Wrapping it up in a subroutine seems like overkill; you weren't considering THAT, were you?

I think the function is stunning, BTW. I'm still wrapping my head around it. One may be able to make its workings more obvious, but I can't help you, as I barely follow how it works. Perhaps my self-declared confusion will prompt some of the Enlightened to elaborate.

ry

"I'm not afraid of Al Quaeda. I'm afraid of Al Cracker." -Chris Rock


Comment on Re: Build tree data structure from DB (flat) data; function golf

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (15)
As of 2014-07-24 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (167 votes), past polls