in reply to more with directory contents

To test whether some "file" is a directory, this logic will work:
if (-d $filename) { print "directory\n"; } else { print "other\n"; }

So if you have @filenames, you can filter it into @files and @dirs with this sub:
sub filter_names { my ($nref,$fref,$dref) = @_; for (@$nref) { if (-d) { push @$dref, $_; } else { push @$fref, $_; } } }

Call it like:
filter_names(\@filenames,\@files,\@dirs);

that ok?
Update: Oops Chmrr said the same thing already... sorry.