Emilio Casbas wrote:
> Hi,
Hello,
> 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
my $dir = '/tmp';
opendir my $dh, $dir or die "Cannot open '$dir' $!";
print "$dir\n",
map !/\A\.\.?\z/ && -d "$dir/$_" ? "$dir/$_\n" : (),
readdir $dh;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>