use File::Spec::Functions qw/no_upwards/; ... my @file_list = no_upwards readdir($dirhandle);