#! /usr/bin/perl -w

use strict;

my $f;

while (<STDIN>)
{
	if (/<s id="FILENAME:(.*)">/)
	{
		close $f if defined $f;
		open $f, ">$1" or die "Cannot open the file $1\n";
	}
	else
	{
		print $f $_;
	}
}

close $f;
