#! /usr/bin/perl

# Run: test.pl < test.pl | more

use strict;

for (<>) {
        my @a = split(/<!--\s*((\S+)\s+?(\S+)?)\s*!-->/);
        my @b = ();

        push(@b, [splice(@a, 0, 4)]) for (@a);
        push(@b, [@a]) if (@a);

        for (@b) {
                print("@{$_}[0]")     if (@{$_}[0]);
                print("@{$_}[2]")     if (@{$_}[2]);
                print(" as @{$_}[3]") if (@{$_}[3]);
        }
}

__END__

<?xml version="1.0" encoding="<!-- xml:encoding !-->">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<!-- xml:lang !-->">

<head>
	<title><!-- page:title !--> / <!-- page:subtitle !--></title>

	<!-- @meta:meta,content meta !-->

	<!-- @link:rel,type,href,media link !-->
</head>

<body>
	<div id="<!-- css:#header !-->">

		<h1><!-- page:title !--></h1>
		<h2><!-- page:subtitle !--></h2>

		<ul>
			<!-- @menu:href,description a,li !-->
		</ul>
	</div>
</body>

</html>
