I am very new to perl myself. I was having the same type of problem the
other day. I came up with the following which has worked for me, but like I
said I am a newbie, so it could prolly be done much better:
#!/usr/bin/perl
use File::Find;
@DIRS = ('.') unless @ARGV;
%seen = ();
$lastArtist = $lastAlbum = '';
do {
$moredirs = 0;
find \&getDirs, @DIRS;
} while ($moredirs > 0);
find \&doSomething, sort {lc $a cmp lc $b} @DIRS;
sub getDirs {
if (-d){
unless ($seen{$File::Find::name}) {$moredirs++;}
push @DIRS, $File::Find::name unless $seen{$File::Find::name}++;
}
}
sub doSomething {
print $_, "\n";
}
I don't know why yours works one place and not another. I only tried mine in
one place, which is a smbmount on a linux box. It works now with the above
though.
Hope this helps, I'm curious to see what others have to say.
Patrick
> [EMAIL PROTECTED] wrote:
>
> I am probably doing something very wrong here, but can someone tell me
> why
>
> #!/usr/bin/perl -w
>
> use File::Find;
>
> print "$arg";
> open(LISTFILE, "> /home/meyeo/testfile") or die "Can't open the ffin
> thingy!";
> print LISTFILE "\n";
> close(LISTFILE);
>
> find (\&wanted, $arg);
>
> sub wanted
> {
> # this should print all the files in the serving directory (including
> subdirs)!
> open(LISTFILE, ">> /home/meyeo/testfile") or die "Can't open the ffin
> thingy!";
> print LISTFILE "$_\n";
> close(LISTFILE);
> }
>
> does list all the files when i do 'listfiles /myhomedir' (including
> subdirs)
> and lists only the dirnames when i do 'listfiles /cdrom'?