I've written a script that, at one point, creates a
temporary directory, creates a symlink of a file in that
directory, then does some other stuff. After performing
some unrelated stuff, it uses unlink to delete the symlink.
Or, that's what I was hoping would happen. Instead,
unlink reports in $! that the file does not exist. Here's
a snippet from my code:
# This part works beautifully...
$pathToFiles = '/home/pencilneckgeek/files';
$tempDir = '/home/pencilneckgeek/tmp/' + random(10000);
mkdir($tempDir) or die "mkdir: $!\n";
$origFile = "$pathToFiles/theFile.txt";
$theLink = "$tempDir/theFile.txt";
symlink($origFile, $theLink) or die "symlink: $!\n";
# do some stuff...
...
# now, here's where the problem lies...
unlink($theLink) or die "unlink: $!";
which dies at the unlink, reporting
"unlink: No such file or directory"
$theLink doesn't change at all at any point in the code -
the file's path/name is simply sent off to another program
(which currently does nothing)...
Any ideas?
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.