#!/usr/bin/perl -w use strict; print join("\n", grep{-f&&/\.foo\z/}map{<$_/*>}grep{-d}'.',map{"./$_"}<*> ), "\n";