in reply to A looping question

I always find that that it's a real drag having to supply any keyboard input (beyond a basic "y/n" confirmation) to a perl script while it's running. (Same goes for any command-line tool.) The more such input is needed, the sooner I tend to regard the tool as not worth using. (Update: Of course, I'm not referring to tools that actually involve shell-like interaction with the user, such as the perl debugger or the cpan shell; I'm just talking about tools where all the needed information can be specified at start-up.)

A decent command-line shell offers things like path-name completion (type a few characters and hit the tab key), and command history with easy recall(/edit)/rerun of previous commands, to minimize the amount of typing needed.

IMHO, the start of your script should just be:

use strict; use warnings; my $Usage = "Usage: $0 [-f] directory_path\n"; my $force; if ( @ARGV > 1 and $ARGV[0] eq '-f' ) { $force = shift; } die $Usage unless ( @ARGV == 1 ); my $dirname = shift; if ( -e $dirname and ! $force ) { die "$dirname exists. Use '-f' option to delete the existing $dir +name\n$Usage"; } ...
That way, if the person typed an existing path name by mistake, they just recall, edit and rerun the command line. If they already know that the existing path name should be deleted/replaced, they include "-f" on the command line. Now, the operation can be run as part of in any shell script (or another perl script), and can run without manual intervention (e.g. as a scheduled task).

If there are other run-time user decisions to be handled, which should be provided by means of additional command-line options, then you'll want to get acquainted with Getopt::Long or Getopt::Std (which come as core modules with Perl).