Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to print unique directory names and only directory names(not the absolute path).Can anyone suggest how can I get unique dirs and only the dir names?

#!/usr/bin/perl use warnings; use strict; use Cwd; use File::Find; my $cwd = getcwd(); open(my $FILES_FOLDERS, '+>', "files_folders.txt") or die $!; find(sub { print $FILES_FOLDERS "$File::Find::dir\n" ;#Ho +w to print unique directories and get only the directory name } , "$cwd" );

Replies are listed 'Best First'.
Re: How to print unique directores
by wind (Priest) on Mar 17, 2011 at 06:51 UTC
      Thank you
Re: How to print unique directores
by Nikhil Jain (Monk) on Mar 17, 2011 at 06:54 UTC
    To get only the dirname see File::Basename - Parse file paths into directory, filename and suffix.
Re: How to print unique directores
by Anonymous Monk on Mar 17, 2011 at 06:48 UTC
    use Path::Class; print dir($File::Find::dir)->dir_list(-1);