Maybe something like "use re 'debug'"?

https://perldoc.perl.org/re#'debug'-mode

There's a bunch of options, and it seems to be present, at least in some form, 
as early as Perl 5.10?

Ricky

________________________________________
From: Boston-pm <boston-pm-bounces+remorse=mgh.harvard....@pm.org> on behalf of 
em...@greglondon.com <em...@greglondon.com>
Sent: Friday, February 25, 2022 1:19 PM
To: boston-pm@pm.org
Subject: [Boston.pm] more specific regex error messages?

        External Email - Use Caution

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.

suggestions?
Greg




_______________________________________________
Boston-pm mailing list
Boston-pm@pm.org
https://secure-web.cisco.com/1zBy9_BqbfQnntf_x4Qgy8mfHyQaN3gK1FCYKK7rJdR-NaPaore3cOEpItzbBEmpOZon9iCVy4yyPfhRQo9PS4Rpyx3xzWpI1sq5Rj-crQoOfa-JnDr7Yk_p0Q45uIOztjqhwH1RlzjPPxlEFvjP041-80anAdLmINmOPiZvXP07xQq8WIjYYNbe0D4nVOOSLuCvUrikt1Iain4rOdWw0Z88U2exPvx777acH7j65KzWfQOU1Yo5Na6gz_fSwQh5xZNCuAFNRNg_rdwSDEanxwgP1aDNIJv62KeQvQbSoeDmCnB2_DjzZjCVXEs_LLQTeBT-weqfKqxuTwgcnVCty3A/https%3A%2F%2Fmail.pm.org%2Fmailman%2Flistinfo%2Fboston-pm


_______________________________________________
Boston-pm mailing list
Boston-pm@pm.org
https://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to