On 25/02/2022 18:19, [email protected] wrote:

I have a rather complex regex that I'm throwing text at.

if($str=~m/\Athing1\:thing2\,thing3\@(\w+)\?(\d+)\Z/){
    # process str
} else {
    die "bad str 'str' ";
}

Is there a way to get better built in reporting with regexps?
with the above, if the string doesn't match, I get "bad input".

What I'd rather get is something like "expecting \:thing2"

if need be, I'll break it into a series of nested ifs.
but that would be exceedingly ugly.

The pattern does not require backtracking.
I've already checked that I'm in a certain location and only one kind of input is expected.

and again, I can't load external modules at work.

That sounds like the most important problem for you to solve. If you can't use the CPAN then you're going to have to rewrite some of it yourself, at your boss's expense, and doing that correctly means writing lots of difficult, ugly code.

That said, I don't think that there's an easy way to do what you want with regexes.

--
David Cantrell

_______________________________________________
Boston-pm mailing list
[email protected]
https://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to