#!/usr/bin/perl -w
my $n=0;
local $/='OggS';
while (<>) {
    if (s/(^.{24}\001vorbis.*)//) { # first vorbis header packet
	# note: assuming non-multiplexed vorbis-only stream!
	if ($n++) {
	    print F;
	    close F;
	}
	open(F,">$n.ogg") or die $!;
	print F "$/$1";
    } else {
	print F unless length $_==4;
    }
}
