#! / usr / bin / perl -w
use strict;
use File :: Spec;
local $ \ = "\ n"; # Add a newline character to the output of each line of the current module
my% options;
#Directory path
$ options {single_case} = ‘/ home / jiangyu / src / pl / Example’;
my @cases;
if (-d $ options {single_case}) {# Determine whether the directory exists
my @files;
my $ dh;
push (@files, $ options {single_case});
while (@files) {
if (-d $ files [0]) {#If it is a directory, perform the following operations
opendir $ dh, $ files [0] or die $ !; #Open the directory handle and print an error message if it fails
@_ = grep {/^[^\.]/} readdir $ dh; #filter out files with "." and "..", which are hidden files under UNIX
foreach (@_) {
push (@files, File :: Spec-> catfile ($ files [0], $ _)); #Connect directory name and file name to form a complete file path:
}
closedir $ dh;
}
#If the file is directly pressed into the array @cases
elsif ($ files [0] = ~ /\.t$/) {
push (@cases, $ files [0]);
}
shift @files;
}
}
else {
@cases = ($ options {single_case});
}
print $ _ foreach @cases; #print file list