# find something like @interface push @stack, 'interface'; # parse lines until reaching a closing curly my $tagname = pop @stack; print "";