my $path = 'yourdir/yoursubdir/'; # or whatever my @filearray; while (<$path*>) { s/$path//; # strip off the filepath push @filearray, $_; # push the filename into the array }