#!/path_to_perl use Parse::RecDescent; $::RD_ERRORS = 1; #Parser dies when it encounters an error $::RD_WARN = 1; #Enable warnings - warn on unused rules &c. $::RD_HINT = 1; # Give out hints to help fix problems. my $grammar = <<'END_OF_GRAMMAR'; # What you said... start : '(' section(s) ')' section : '(' id entry(s) ')' entry : '(' section | keypair ')' keypair : '(' key value ')' END_OF_GRAMMAR my $text; while () { my $new_line = $_; chomp; $text = "$text $new_line"; } my $parser = Parse::RecDescent->new($grammar) or die "Ha Ha, something is wrong with the syntax, good luck finding the issue!\n"; defined $parser->section($text) or die "It helps if there is a section to find...";