use strict;

my $status = 0;
my $x = 0;
my $y = 0;
my $w = 0;
my $h = 0;

my $mx = 0;
my $my = 0;
my $dx = 0;
my $dy = 0;

my @c = ();
my @l = ();

my @cc = ();
my @cl = ();

while (<>)
{
	if ($status == 0)
	{
		if (m/name="(.*?)".*parent-style-name="occupazione"/)
		{
			push @cc, $1;
		}
		elsif (m/name="(.*?)".*parent-style-name="letto"/)
		{
			push @cl, $1;
		}
		elsif (m/draw:style-name="(.*?)".*?svg:width="(.*?)cm".*?svg:height="(.*?)cm".*?svg:x="(.*?)cm".*?svg:y="(.*?)cm"/)
		{
			my $found = 0;
			my $style = $1;
			$w = $2;
			$h = $3;
			$x = $4;
			$y = $5;

			$mx = $x + $w if $x + $w > $mx;
			$my = $y + $h if $y + $h > $my;

			$dx = $x if $dx == 0 || $x < $dx;
			$dy = $y if $dy == 0 || $y < $dy;

			foreach (@cc)
			{
				$status = 1 if $style eq $_;
			}
			foreach (@cl)
			{
				$status = 2 if $style eq $_;
			}
		}
	}
	elsif ($status == 1 || $status == 2)
	{
		m/>(.*?)</;
		my $l = $1;

		push @c, $l if $status == 1;

		$status = 0;
	}
}

@c = sort @c;

print "[";

for (my $a = 0; $a < scalar @c; $a ++)
{
	my $n = $c[$a];

	print "\"$n\"";
	print "," if $a < scalar @c - 1;
	
}

print "]";
