Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

filehandler confusion

by dusk (Friar)
on Feb 21, 2001 at 08:37 UTC ( #59851=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://59851]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2022-11-28 20:47 GMT
Find Nodes?
    Voting Booth?