title: How do I search for a particular file in a directory using Perl?
body: <p>I have a file in a directory and i want to pick one particular file from the directory at a time.</p>
  
  <p>Code is given below:</p>
  
  <pre><code>$xml_file_name = &lt;STDIN&gt;;
  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;
  }
  </code></pre>
  
  <p>I am inputting the file name to be returned as <code>sample.xml</code>. But in the <code>@dirs_found</code> variable, all the file names that starts with 's' are getting stored.</p>
  
  <p>How to find out the exact one file at a time?</p>