use strict; use warnings; my @stack = @ARGV; while (my $path = shift @stack) { my @dir_entries = glob("$path/*"); foreach my $entry (@dir_entries) { print $entry, "\n" if -f $entry; push @stack, $entry if -d $entry; } }