in reply to "Too Many Files Open" problem

THANK YOU ALL!

I've simplified the code greatly. See below. After 2045 files I get this:

WAV/j_Wah.wav: unable to open file (Too many open files)

I used the 'handle' program and indeed the read files are staying open. Any thoughts? Thanks!

use Audio::Wav; my @wavs = glob ("WAV\/*.wav"); while (1) { for my $wav (@wavs) { print "$wav\n"; my $readwav = new Audio::Wav; my $read = $readwav -> read( "$wav" ); my $src_details = $read -> details(); $readwav = undef; $read = undef; } }

Replies are listed 'Best First'.
Re^2: "Too Many Files Open" problem
by Anonymous Monk on Jan 07, 2012 at 08:14 UTC

    Hi

    I'd offer a fix, but I'm just so disgusted, report to author :)

    as a workaround you can use      $read->{handle}->close; in your loop

    my  Audio-Wav-0.12\xt\bug.filehandles.t based on your program

      That did it!

      You have my deepest thanks. I spent a long time banging my head against a wall thinking I must be missing something really dumb. I never would have solved this without your help...