#!/usr/bin/perl -w use strict; my $user = 'SOME_USER'; my $directory = "c:/documents and settings/$user/"; opendir (MYDIR, $directory) || die "unable to open $directory"; my @file_paths = map {"$directory/$_"} grep{ -f "$directory/$_" } readdir MYDIR; # The below means the same thing. But I think that the # above grep/map filter combo is easier to understand. #my @file_paths = map { -f "$directory/$_" # ? "$directory/$_" # : () # } readdir MYDIR; # # return"()" from a map{} to return "nothing" # to get all the files (directories are files).... # my @file_paths = map{ "$directory/$_"} readdir MYDIR; foreach my $file (@file_paths) { print "$file\n"; }