Having Trouble Recursing a Function
From: Mark Healey (die_at_spammer.die)
Date: 02/24/05
- Next message: Richard Lawrence: "Re: XML:Simple and arrays of hashes"
- Previous message: Alan J. Flavell: "Re: Division/math bug in perl?"
- Next in thread: Jim Gibson: "Re: Having Trouble Recursing a Function"
- Reply: Jim Gibson: "Re: Having Trouble Recursing a Function"
- Reply: Dave Weaver: "Re: Having Trouble Recursing a Function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 24 Feb 2005 22:40:44 GMT
Can anyone tell me why the following only goes one level deep in the
directory tree?
I'm stumped
#!/usr/bin/perl
use strict;
use Cwd;
my $cdir;
my @files;
$cdir = getcwd();
doDir($cdir);
foreach(@files)
{
printf("$_\n");
}
exit;
sub doDir
{
my $dir = $_[0];
printf("####$dir####\n");
my $fname;
opendir(DIRHANDLE, $dir);
my @list = readdir(DIRHANDLE);
closedir(DIRHANDLE);
foreach(@list)
{
chomp;
if(-d $_)
{
unless(/\.\.?\z/)
{
$fname=$dir.'/'.$_;
doDir($fname);
}
}
else
{
if(/\.mp3\z/)
{
$fname=$dir.'/'.$_;
push(@files, $fname);
}
}
}# end foreach(@list)
}# end doDir()
TIA
-- Mark Healey marknews(at)healeyonline(dot)com
- Next message: Richard Lawrence: "Re: XML:Simple and arrays of hashes"
- Previous message: Alan J. Flavell: "Re: Division/math bug in perl?"
- Next in thread: Jim Gibson: "Re: Having Trouble Recursing a Function"
- Reply: Jim Gibson: "Re: Having Trouble Recursing a Function"
- Reply: Dave Weaver: "Re: Having Trouble Recursing a Function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|