Penggu has asked for the wisdom of the Perl Monks concerning the following question:
I wrote a small piece of code which ideally (to my understanding anyway) be working. Basically what it does (supposed to) is recurse folders from the current dir, making a symlink in each one to a file given on the command line. It's working at the moment, but it wont go deeper then one level, although output says otherwise.
Here's the code:
The output seems fine:#!/usr/bin/perl use File::Find; if (!-f $ARGV[0]) { die "File \"$ARGV[0]\" does not exist"; } sub wanted { if (length $_ == 1) { return; } if (-d) { $temp = '../' x (split(/\//,$File::Find::name) - 1).$ARGV[0]; $target = $File::Find::name.'/'.$ARGV[0]; print $target," -> ",$temp,"\n"; symlink($temp,$target); } } find(\ &wanted,'.');
shell# ./recurlink.pl index.php ./Automotive/index.php -> ../index.php ./Automotive/Mechanics/index.php -> ../../index.php ./Banking_and_Finance/index.php -> ../index.php ./Fast_Food_and_Groceries/index.php -> ../index.php ./Fast_Food_and_Groceries/Take_Away_Shops/index.php -> ../../index.php ./House_and_Building/index.php -> ../index.php ./Educational_Institutions/index.php -> ../index.php shell#but on inspection, only the 1st level symlinks are created. none of the others exist.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: recursive directory linking
by cwest (Friar) on Jul 28, 2000 at 23:25 UTC | |
|
RE: recursive directory linking
by Anonymous Monk on Jul 29, 2000 at 00:34 UTC | |
by knight (Friar) on Jul 29, 2000 at 02:53 UTC | |
by kirbyk (Friar) on Jul 29, 2000 at 04:37 UTC | |
|
Re: recursive directory linking
by Penggu (Initiate) on Jul 29, 2000 at 18:02 UTC |