use CWD; my $org_dir = cwd; chdir($desired_dir) || die "can't cd: $!"; opendir(DIR, $desired_dir) || die "can't opendir: $!"; while(my $file = readdir DIR){ next if -d $file; # preform operations below on $file } closedir DIR; chdir($org_dir) || die "can't get back to $org_dir: $!";