in reply to Search & Replace repeating characters

For example, my directory is "c:\\temp\\\\" (ending with 4 back slashes). ... $ScriptDir="C:\\temp\\\\";

Note that this string doesn't end in four backslashes, it ends in two - "\\" represents a single backslash. Anyway, File::Spec's canonpath is your friend:

use File::Spec::Win32; my $ScriptDir="C:\\temp\\\\"; print $ScriptDir,"\n"; # => C:\temp\\ $ScriptDir = File::Spec::Win32->canonpath($ScriptDir); print $ScriptDir,"\n"; # => C:\temp