title: Perl Get Parent Folder Name
body: <p>What is the solution to get the name of the parent directory using File::Find. I know how to get only the filename or only the directory path but I don't know how to do this for the last containing directory. </p>
  
  <p>For example, if the directory is <code>/dir_1/dir_2/dir_3/.../dir_n/*.txt</code> I need to get the '<code>dir_n</code>' name.</p>
  
  <pre><code>use strict;
  use warnings;
  use File::Find;
  
  my $dir = "some_path";
  
  find(\&amp;file_handle, $dir); 
  sub file_handle {
      /\.txt$/ or return;
      my $fd = $File::Find::dir;
      my $fn = $File::Find::name;
      # ...
  }
  </code></pre>