sub validateMaketextParams { my $text = shift; # from Locale::Maketext my $in_group = 0; # start out outside a group my @c; while($text =~ # Iterate over chunks. m/( [^\~\[\]]+ # non-~[] stuff (Capture everything else here) | ~. # ~[, ~], ~~, ~other | \[ # [ presumably opening a group | \] # ] presumably closing a group | ~ # terminal ~ ? | $ )/xgs ) { #print STDERR "chunk = $1\n"; if($1 eq '[' or $1 eq '') { # "[" or end $in_group = 1; } elsif($1 eq ']') { # "]" $in_group = 0; my ($method, @params) = split(/,/, $c[-1], -1); #print STDERR "method='$method'\n"; throw Error::Simple("invalid method $method") unless $method =~ /^(_\*|_\-?\d+|\*|\#|quant|numf|numerate|sprintf)$/; } push @c, $1; } return 1; }