In a program I'm working on, I build a hash "tree" of sorts that contains package dependencies. Each key contains an array with the first level dependencies of the key. Each one of those dependencies have their own key with their first level dependencies in the hash. For example:

my %tree = { package1 => [ package2, package3, package4 ],
             package2 => [ package7 ],
             package3 => [ package5 ],
             package4 => [ package7, package6],
             package5 => [ ],
             package6 => [ ],
             package7 => [ ] };

Now, I want to walk the tree starting with a known "package1" and build an ordered list of packages to install. For example:

package7
package2
package5
package3
(no package7 here because it is already in the list)
package6
package4
package1

I also want to be able to track what package is a dependency of what (which key a certain value is under) with my tree structure. What is the easiest way to do this? Is there a better way to do this?

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to