Ad Hoc parsing

bart on 2006-11-26T18:54:04

In his POD for Text::Sprintf::Named, Shlomi Fish writes:

ACKNOWLEDGEMENTS
The (possibly ad-hoc) regex for matching the optional digits+symbols parameters' prefix of the sprintf conversion was originally written by Bart Lateur (BARTL on CPAN) for his String::Sprintf module.
I could have provided a very strict check for the formatting data, but it wouldn't have been very useful. At the time the formatter is built, the formatting string is not yet passed to it. That happens when you actually try to use it as a formatting template.

So I chose to let the actual semantic checks on whether this field contains nonsense or not, depend on the callback, or, usually, to the native sprintf if that is what it's built upon. As this happens at roughly the same time as the original check would have run, that'll do just as well, and it'll be faster, anyway.