while(my $file = readdir DIR) { next if $file =~ /^./; # still working with name only $file = File::Spec->catfile( $dir, $file ); next unless -f $file; # working with full path from now on # ....... proceed with the rest of loop };