Emilio Casbas am Montag, 18. September 2006 17:11:
> Hi,

Hi Emilio

> 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?

#!/usr/bin/perl
use strict; use warnings;

print map "$_\n", grep -d, ($_, <$_/*>) for @ARGV;

__END__

Although I'm not sure if this is the recommended way
- so please wait for other answers :-)

Dani




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


  • File... Emilio Casbas
    • ... Jack Faley ( Who's going to take me serious without a laser pointer?)
    • ... D. Bolliger
    • ... John W. Krahn
      • ... Beginner
        • ... David Romano
        • ... John W. Krahn
      • ... Emilio Casbas
    • ... Mumia W.

Reply via email to