I have a file in a directory and i want to pick one particular file from the directory at a time.
Code is given below:
$xml_file_name = <STDIN>;
chomp ($xml_file_name);
@o = file_search($xml_file_name);
print "file::@o\n";
sub file_search
{
opendir (DIR, "/home/sait11/Desktop/test/Test cases") or die "Failed to open directory\n";
@dirs_found = grep { /$xml_file_name/ } readdir DIR;
closedir (DIR);
# print "dir ::@dirs_found\n";
return @dirs_found;
}
I am inputting the file name to be returned as sample.xml
. But in the @dirs_found
variable, all the file names that starts with 's' are getting stored.
How to find out the exact one file at a time?