in reply to 2 remaining problems (regex)
Just a hint for the future: specifications help, and examples help too.
So, another whack at this:
my @prefix; while (<>) { next if /^#/; # skip comments, apparently if (/^\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 $_"; } }
But the real question I gotta ask is, "did you learn anything, or did I just do your homework for you?"
-- Randal L. Schwartz, Perl hacker
|
|---|