while (glob "$CurrentDir/*"){ $temp = $_; # Remainder of the code is the same.