use strict; use warnings; my $dir; while ( (print "enter directory; "), $dir= and $dir =~ /\\\\|\/\//g) { print "invalid directory syntax... double ", '// or \\\\', " not allowed!\n"; } $dir =~ s/^\s*|\s*$//g; #remove leading and trailing spaces print "INPUT LOOP says $dir\n"; __END__ C:\Monks>perl CommandLoopNoDoubleSlash.pl enter directory; C:\\x invalid directory syntax... double // or \\ not allowed! enter directory; D:\x\temp// invalid directory syntax... double // or \\ not allowed! enter directory; C://x invalid directory syntax... double // or \\ not allowed! enter directory; C:/X INPUT LOOP says C:/X