in reply to Re^3: check if it is a file or directory
in thread check if it is a file or directory

I incorporated elements of your script into this:
#!/usr/bin/perl use strict; use warnings; use Path::Extended::Dir; my $dir = Path::Extended::Dir->new('/root/Desktop'); $dir->open; chdir($dir); while( my $entry = $dir->read($dir) ) { next if $entry =~ /^\./ or -f $entry; print $entry, "\n"; } $dir->close;
I decided to use Path::Extended::Dir to try to get better control.