Last active
September 10, 2023 22:48
-
-
Save m0rb/fe9969a2242410c19026626880d89224 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use warnings; | |
my $header = 'RIFF'; | |
my $sbuf = 1024; | |
open my $file, '<', $ARGV[0] or die $!; | |
binmode $file; | |
my $i = 0; | |
while (<$file>) { | |
seek($file, $i, 0); | |
my $buf; | |
read $file, $buf, $sbuf; | |
my $y = index $buf, $header; | |
if ($y != -1) { | |
$i += $y + 4; | |
seek $file, $i, 0; | |
read $file, $buf, 6; | |
my $size = unpack("V", $buf) + 8; | |
seek $file, ($i - 4), 0; | |
read $file, $buf, $size; | |
open(my $out, ">", $ARGV[1]) or die $!; | |
print $out $buf; | |
close $out; | |
$buf = undef; | |
} | |
$i += $sbuf - length($header); | |
} | |
close $file; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment