Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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
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? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2021-12-02 16:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (22 votes). Check out past polls.

    Notices?