in reply to Why is "If" condition not working
readdir returns the a directory entry, not a full path. You need to do something like:
if (-f "$dirname\\$file1") {
Note that it is a bad idea to overload variable names. Your sample code uses file1 as both an array name and as the name of a scalar variable - bad, bad bad! Also, if you find yourself tacking a number on the end of a variable name then you probably want to be using an array instead, but that may be a different lesson.
|
|---|