foreach $file in @directory { if the $file is a directory { assign an implicit split to @_ (deprecated) to $file; # hmmm assign the seventh element of @fields to $file and match a regex; # hmmm print the capture from the previous regex; explicitly go to the next element; } } #### use File::Basename; my $fname = basename($path);