#!/usr/bin/perl use strict; use warnings; my $runTest = 'one.d,ants,mail,3chess.pl,two.d'; sub dive { map { -d $_ ? dive( glob "$_/*" ) : $_ } @_ } my @files = map { dive($_) } split /,/, $runTest; print "$_\n" for @files;