use strict; use warnings; use Parse::RecDescent (); my $grammar = <<'__END_OF_GRAMMAR__'; { use strict; use warnings; } parse : text ';' num_list(4) /\z/ { [ $item[1], map { @$_ } @{$item[3]} ] } num_list : float junk { $item[1] } text : ... float : ... junk : ... __END_OF_GRAMMAR__ my $parser = Parse::RecDescent->new($grammar) or die("Bad grammar\n"); my $rv = $parser->parse($text) or die("Bad text\n");