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.
In reply to recursive directory linking by Penggu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |