ovedpo15 has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks!
I have a hash of links %links. The key is the source of the link and the value is the target of the link.
I'm trying to create a script which creates those links (by using ls -s [target] [source]).
At first I thought that it does not really matter the order of creating the links. So I did:
foreach my $link (keys(%links)) { my $target = $links{$link}; print $fh "ln -s $target $link\n"; }
The problem is with a link that dependent on another link. So for example if I have those links:
ln -s ../python2/2.7.15 /usr/pkgs/python/2.7.5 ln -s /nfs/tools/data /usr
So in that case, since we create /usr only after trying to create /usr/pkgs/python/2.7.5 it will fail.
Is it possible to suggest a strategy on how to find the right order of the links?

Replies are listed 'Best First'.
Re: Order of links
by haukex (Archbishop) on Apr 29, 2021 at 10:23 UTC

    I gave you a solution to this issue here.