#!/usr/bin/perl -w use strict; my $dirname="/path/to/the/directory"; opendir(DIR,$dirname) or die "$dirname:$!"; while (my $entry=readdir(DIR)){ next if $entry eq '.'; next if $entry eq '..'; next if -d $entry; # see notes below | do something with this... } exit(0);