> #!/usr/bin/perl
> 
> 
> use strict;
> use warnings;
> 
> sub get_subdirectories{
>         # retrieves list of directories from passed directory
>         # returns directory list as an array
> 
>         my $directory = shift;
>         open LS, "ls -l $directory|";
>         local $/ = undef;
>         my @dirs =  grep {s/^d.*?\s*?(\w*)$/$1/} split ( /\n/, <LS>);
> 
> 
> }
> 
> 
> my @results = get_subdirectories("/home/corenth");
> 
> print @results;
> 
> __END__

Try this, you don't need to shell out. It returns an array of
subdirectories.

opendir LS, $directory or die "Can't opendir $directory: $!";
my @dirs = grep { -d $_ } readdir LS;
closedir LS;
return @dirs;

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


Reply via email to