my @tokens; while ($input =~ /\G( pattern... )/gcx) { push @tokens, $1; } if (pos $input < length $input) { say "Parse error at ...."; }