my @p; while () { push @p, [], if /^Window/; push @{$p[-1]}, $_; }