title: Create directory tree in Path-Class-Dir module
body: <p>The <a href="https://metacpan.org/module/Path%3a%3aClass" rel="nofollow"><code>Path::Class</code></a> module is a top-rated module and has very good <a href="http://cpanratings.perl.org/dist/Path-Class" rel="nofollow">reviews</a> at cpan.org. I wonder whether the <a href="https://metacpan.org/module/Path%3a%3aClass%3a%3aDir" rel="nofollow"><code>Path::Class:Dir</code></a> module can create directory tree like this*:</p>
  
  <pre class="lang-none prettyprint-override"><code>/home/scottie/perl/lib/Path-Class-0.25
    -&gt; lib/
       -&gt; Path/
          -&gt; Class/
             -&gt; Dir.pm
             -&gt; Entity.pl
             -&gt; File.pl
          -&gt; Class.pl
    -&gt; t/
       -&gt; 01-basic.t
       -&gt; 02-foreign.t
       -&gt; 03-filesystem.t
       -&gt; 04-subclass.t
       -&gt; 05-traverse.t
       -&gt; author-critic.t
    -&gt; Build.PL
    -&gt; Changes
    -&gt; dist.ini
    -&gt; INSTALL
    -&gt; LICENSE
    -&gt; Makefile.PL
    -&gt; MANIFEST
    -&gt; META.yml
    -&gt; README
    -&gt; SIGNATURE
  </code></pre>
  
  <p>*) Source: <code>Path-Class-0.25.tar.gz</code> file and "/" at the end of string indicated directory (like <code>ls -p</code> in *nix systems)</p>
  
  <p>And <strong>not</strong> like this (full path from root):</p>
  
  <pre class="lang-none prettyprint-override"><code>  /home/scottie/perl/lib/Path-Class-0.25
    -&gt; /home/scottie/perl/lib/Path-Class-0.25/lib/
       -&gt; /home/scottie/perl/lib/Path-Class-0.25/lib/Path/
          -&gt; /home/scottie/perl/lib/Path-Class-0.25/lib/Path/Class/
             -&gt; /home/scottie/perl/lib/Path-Class-0.25/lib/Path/Class/Dir.pm
             -&gt; /home/scottie/perl/lib/Path-Class-0.25/lib/Path/Class/Entity.pl
             -&gt; /home/scottie/perl/lib/Path-Class-0.25/lib/Path/Class/File.pl
          -&gt; /home/scottie/perl/lib/Path-Class-0.25/lib/Path/Class.pl
    -&gt; /home/scottie/perl/lib/Path-Class-0.25/t/
       -&gt; /home/scottie/perl/lib/Path-Class-0.25/t/01-basic.t
       -&gt; /home/scottie/perl/lib/Path-Class-0.25/t/02-foreign.t
       -&gt; /home/scottie/perl/lib/Path-Class-0.25/t/03-filesystem.t
       -&gt; /home/scottie/perl/lib/Path-Class-0.25/t/04-subclass.t
       -&gt; /home/scottie/perl/lib/Path-Class-0.25/t/05-traverse.t
       -&gt; /home/scottie/perl/lib/Path-Class-0.25/t/author-critic.t
    -&gt; /home/scottie/perl/lib/Path-Class-0.25/Build.PL
    -&gt; /home/scottie/perl/lib/Path-Class-0.25/Changes
    -&gt; /home/scottie/perl/lib/Path-Class-0.25/dist.ini
    -&gt; /home/scottie/perl/lib/Path-Class-0.25/INSTALL
    -&gt; /home/scottie/perl/lib/Path-Class-0.25/LICENSE
    -&gt; /home/scottie/perl/lib/Path-Class-0.25/Makefile.PL
    -&gt; /home/scottie/perl/lib/Path-Class-0.25/MANIFEST
    -&gt; /home/scottie/perl/lib/Path-Class-0.25/META.yml
    -&gt; /home/scottie/perl/lib/Path-Class-0.25/README
    -&gt; /home/scottie/perl/lib/Path-Class-0.25/SIGNATURE
  </code></pre>
  
  <p>I tried to do it but there is something wrong with my code:</p>
  
  <pre class="lang-perl prettyprint-override"><code>#------------------8&lt;------------------
  my $dir = Path::Class::Dir-&gt;new('/home/scottie/perl/lib/Path-Class-0.25');
  
  my $nfiles = $dir-&gt;traverse(sub {
      my ($child, $cont) = @_;
      return if -l $child; # don't follow symlinks
  
      #print Dumper($child);
      #print "$child\n";
  
      print $child-&gt;{'dir'}{'dirs'}[-1];
      print " -&gt; ";
      print $child-&gt;{'file'};
      print "\n";
      return $cont-&gt;();
  });
  #------------------8&lt;------------------
  </code></pre>
  
  <p>Could you please have a gander at my code and tell me how to make a directory tree without full paths in <code>$child</code>?</p>
  
  <p>Many thanks!</p>
  
  <p>Best regards,<br />
  Scottie</p>