Subject: | Error on close |
MIDI::Opus often fails with this:
error while closing filehandle for /tmp/C_lEGzBDaq.midi: "Bad file
descriptor"
This is the type of use:
unlink('/tmp/xxx.mp3');
} elsif($url =~ /\.midi?$/i) {
my $tmp = File::Temp->new(UNLINK => 1, SUFFIX => '.midi');
open(my $midi, '>', $tmp);
# Extract all text fields from the MIDI file and spider them
# print "MIDI $url\n";
print $midi $$contentref;
close $midi;
my $opus = MIDI::Opus->new({'from_file' => $tmp,
'no_parse' => 0});
foreach my $track ($opus->tracks) {
foreach my $event ($track->events) {
my $type = @$event[0];
if($type =~ /(text|name)/) {
my $text = @$event[2];
foreach (split(/\W/, $text)) {
my $word = prepareWord($_);
unless(ignoreWord($word)) {
# unless($matches{$word}) {
# print "MIDI:
found word '$word'\n";
$matches{$word} = 1;
# }
}
}
}
}
}
$matches{'midi'} = 1;