#!/usr/bin/perl $line = ; $line =~ s/(^\t*)//; $indent = length $1; $delta_indent = $indent; while ($next = ) { $next =~ s/(^\t*)//; $next_indent = length $1; $parens = $delta_indent; if ($indent > $last_indent) { $last_parens ++; print "\t"x$last_indent, "(\t"x($indent - $last_indent), $last; } else { print "\t"x$last_indent, $last, "\t)"x($last_indent - $indent); } print "\n"; $last = $line; $last_indent = $indent; } print "\t"x$last_indent, $last, "\t)"x$last_indent;