dusk has asked for the wisdom of the Perl Monks concerning the following question:

I'm having a bit of trouble in another part of my Napster client. :\ I have a hash (opts) containing
Then, I have the following:
my $shared_songs=0; opendir (S,$opts{share_dir}) || die "Error opening $opts{share +_dir} for sharing: $!"; foreach my $song (readdir(S)) { next unless $song =~ /\.mp3$/; $nap_object->share("$opts{share_dir}/$song",1) && $shar +ed_songs++; } closedir S;
Which, in theory should use S as a filehandler, open the specified share directory And, for each file that is an mp3, share it, and increment the value of $shared_songs by one, until all mp3s have been shared. However, it doesn't share files in the subdirectories. Any suggestions/fixes would be greatly appreciated :)

Replies are listed 'Best First'.
Re: filehandler confusion
by archon (Monk) on Feb 21, 2001 at 08:43 UTC
    You need to traverse the directory structure if you want to get the files in the subdirectories. You should use the File::Find module to do that.