On 09/18/2006 10:11 AM, Emilio Casbas wrote:
Hi,
I have this script;
-------
use File::Find;
$File::Find::no_chdir = 0;
find(\&wanted, @ARGV);
sub wanted {
print "$File::Find::name\n" if(-d);
}
-------
I want to do a directory search for a given ARG, but no a recursive
search, for example
this script show this;
[EMAIL PROTECTED] tmp]# perl script.pl /tmp
/tmp
/tmp/.ICE-unix
/tmp/test_directory
/tmp/test_directory/directory1
/tmp/test_directory/directory1/directory2
/tmp/test_directory/directory1/directory2/directory3
/tmp/lost+found
/tmp/.font-unix
But i want a behaviour like this command;
[EMAIL PROTECTED] tmp]# find /tmp -type d -maxdepth 1
/tmp
/tmp/.ICE-unix
/tmp/test_directory
/tmp/lost+found
/tmp/.font-unix
Any help?
Thanks
Emilio C.
File::Find wants to make it recursive by default, so use File::Slurp
instead:
use File::Slurp;
my @files;
push @files, read_dir for (@ARGV);
print (join "\n", @files), "\n";
WARNING: UNTESTED CODE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>