#!/usr/bin/perl -wT use strict; use File::Spec::Functions qw(catdir rootdir no_upwards); use constant START_DIR => catdir(rootdir, qw(users foo)); opendir DIR, START_DIR or die 'Could not open directory ', START_DIR, ": $!"; while( defined(my $file = readdir DIR) ) { next unless no_upwards($file); print "$file\n"; #...do something with $file } closedir DIR;