in reply to Follow up to:

Perhaps something like this:
my @prefix; while (<>) { next if /^#/; # skip comments, apparently if (/^\s*(\S+)\s*\{\s*$/) { push @prefix, $1; } elsif (/^\s*\}\s*$/) { pop @prefix; # no error checking } elsif (/^\s*(.*)/) { print "@prefix " if @prefix; print $1, "\n"; } else { die "internal error on $_"; } }

-- Randal L. Schwartz, Perl hacker