I want to find certain files in my system (OS X) and create symbolic links to them. For this, I use File::Find. I want to make sure, not to link to the same file twice. So I dont follow links (follow => 0). But what if I want to rerun the process later and don't want to create all the links already present a second time? Is it sufficient to collect, in a first run, all the devicenumbers and inodes of the existing links in my targetdirectory like this:
my %stat;
find ( sub {
my($dev,$ino)= stat $File::Find::name;
++$stat{$dev}->{$ino};
}, $targetdirectory);
and then later check like this:
find( {
wanted => sub {
:
:
# check whether or not we already know of this file
my($dev,$ino)= stat $File::Find::name;
return if $stat{$dev}->{$ino}++;
:
:
},
no_chdir => 1,
follow => 0,
}, '/');
s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
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.