use strict; use Parse::RecDescent; use Data::Dumper; $::RD_ERRORS = 1; $::RD_WARN = 1; $::RD_HINT = 1; $::RD_TRACE = 1; my $grammar = <<'_EOGRAMMAR_'; QUOTED_STRING : /"/ quoted_char(s?) /"/ { " " . join "", @{$item[3]} # leading space flags a string } quoted_char : /[^\\"]+/ | /\\n/ { "\n" } | /\\"/ { "\"" } portDefinition: "dbSetCellPortTypes" QUOTED_STRING QUOTED_STRING portLists QUOTED_STRING portLists: "'" "(" list(s?) ")" list: "(" QUOTED_STRING ")" _EOGRAMMAR_ my $parse = Parse::RecDescent->new($grammar) or die "bad grammar"; undef $/; my $text = <portDefinition($text) or die "bad netlist"; print Dumper[$net];