here's what works for me so far:

#!/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__
-------------------------------

now-  just curious about speeding it up- pehaps a module would be fine,
but i'd like to try this out explicitly. -- i think the s/// is what
bothers
me most.  since i'm not all that comfortable with map() and grep()
especialy in block form (perldoc -f grep and perldoc -f map)  i'm not
sure if what i'm doing really takes advantage of the features that these
functions have to offer.

any advice?

thanks :)

willy
http://www.hackswell.com/corenth 


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