title: How I can remove a directory and its contents using perl?
body: <p>I have a few sub-folders in the main folder. There is a .txt file in each sub-folder. Firstly the code will create the "results" folder in the main folder. And it will search "Frequencies" word in each .txt and print to a new file (in the results folder) the first three columns including "Frequencies" word.
  When I run the code the second time, it should remove the result file. But I get the following error when I run it the second time. How can I remove this directory (results) and its contents? (It will work when you run it firstly)</p>
  
  <p>The error:</p>
  
  <pre><code>Undefined subroutine &amp;main::rmtree called at xxx.pl line 9.
  </code></pre>
  
  <p>The code:</p>
  
  <pre><code>#!/usr/bin/env perl
  use strict;
  use warnings;
  use File::Path qw/make_path/;
  use Cwd;
  
  my $dir = cwd();
  my $check_result_file = "$dir/results/";
  rmtree($check_result_file);
  </code></pre>