if ($fsline =~ /(.:\\.*)/){ $dir = $1; print "$dir\n"; #works fine here } #### $badhost = "$logdir\\BADHOST.csv"; open (BADHOST,">>$badhost"); $dest = "$dir\\$file"; #will print redundancies here $dest =~ s/[\s]//g; $md5sumtmp = `rctrlx.exe $target /u "domain\\username" /p "password" /c md5sum.exe /app md5sum.exe $dest`;