On Fri, Mar 21, 2008 at 5:01 PM, jeevs <[EMAIL PROTECTED]> wrote:
> My question is.. Is there already a perl module which will be able to
> parse the directory structure and give me the required output.
sure.like Filesys::Tree module on cpan.
For example, the code below,
use Filesys::Tree qw/tree/;
my $tree = tree({ 'full' => 1,'max-depth' => 3,'pattern' => qr/\.pl$/ } ,'.');
files($tree);
sub files
{
my %tree = %{+shift};
for (keys %tree) {
if ($tree{$_}->{type} eq 'f'){
print $_,"\n"
}elsif ($tree{$_}->{type} eq 'd') {
files($tree{$_}->{contents});
}
}
}
should get the same results as this unix shell command do,
$ find . -type f -name "*.pl" -maxdepth 2
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/