Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Order of links

by ovedpo15 (Pilgrim)
on Apr 29, 2021 at 10:20 UTC ( #11131858=perlquestion: print w/replies, xml ) Need Help??

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 (Bishop) on Apr 29, 2021 at 10:23 UTC

    I gave you a solution to this issue here.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11131858]
Approved by davido
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2021-10-26 04:28 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (90 votes). Check out past polls.