Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

filehandler confusion

by dusk (Friar)
on Feb 21, 2001 at 08:37 UTC ( [id://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
share_dir->'/foo/bar/'
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 15:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found