I have to admit -- I've never tried this particular task before, but I found it most amusing to build. Perhaps it was the danger that if I did it incorrectly I'd end up without my home directory or something like that :-)
However, I'm happy to announce that this code is tested, it does work, and I'll describe what it does so you know what you're getting yourself into :-)
#!/usr/bin/perl -w
use File::Path;
use File::Basename;
# This extracts the path of the current directory into
# the variable $dirname
my $dirname = dirname($0);
# The following line (beginning with the word "rmtree") is
# commented for safety purposes. It WILL delete the
# contents of the directory the script is in, and all it's
# subdirs. I did test it, but please do not take my word
# for it! Try it in your temp dir before putting this in
# with your live data.
# Uncommenting this line will cause files to be deleted!
# rmtree([$dirname], 1, 1);
print "This is a drill. If this were not a drill, the dir '$dirname',
+ and all of it's contents and subdirectories would be toast right now
+.";
Update: Code has been removed until the original posted states why they want it.. while there are many legitimate reasons for this, there are also plenty of malicious ones.
Update 2: The original poster has posted a very legitimate reason for requiring this functionality. So without further ado, I have re-posted this code. I appologize for the delay, but unfortunatly not everyone is honest these days. Good luck!
-Eric
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.