Maybe a little more verbosity would help.
To speak in terms of Perl, if you have a module Foo which requires module Bar to operate, then there is a dependency. Bar must be installed before Foo. In some cases, such as with RPM, you just can't install Foo until Bar is in place. With Perl, you can install Foo, but it will fail, as it is missing its beloved Bar, and your program won't run.
Maybe Foo also needs the module Baz to run, so that is a second dependency. If you also had a Foo::Bar module, which needed Foo, then you have a second dependency. Perhaps Bar also needs something, say, Fubar, to do its thing.
This leads to a dependency structure that looks like this:
my %dep = (
'Foo' => [ 'Bar','Baz' ],
'Foo::Bar' => [ 'Foo' ],
'Bar' => [ 'Fubar' ],
);
Now the idea is to, based on this specification, figure out what order they
can be installed in such that each module is only installed when all of its dependencies are satisfied. One such order is:
'Fubar','Bar','Baz','Foo','Foo::Bar'
If you install them in this order, there should be no problems. An invalid ordering would be something like:
'Fubar','Foo','Bar','Baz','Foo::Bar'
In this case Foo does not have either Bar or Baz available,
so it can't work. Foo must come after both Bar and Baz.
To answer a question, the order of the dependencies is
not relevant. If Foo requires Bar and Baz, you can list Bar and Baz in any order. After all, they just have to be
present and accounted for. Apart from that, nothing else
matters. This means that the following are equivalent:
'a' => [ 'b','c' ]
'a' => [ 'c','b' ]
These both specify that 'a' requires 'b' and 'c'. It's
like saying that a 'car' needs 'gas' and 'tires' to run.
As long as you have both, you're good to go. Procedure
is irrelevant, as you're not going anywhere until both are
present anyway.
What's interesting about this problem is that at first, it
seems quite difficult to solve, but with a bit of creative
thinking it was really straightforward. It seems to be a
matter of perspective.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.