optimization#
Return a hashref of the optimiser’s compile-time findings for a compiled pattern.
Intended for writing tests that pin optimiser behaviour, not for application logic. The set of keys and the meaning of their values are not a stable API — they change as the optimiser changes, even between minor perl releases.
Synopsis#
use re 'optimization';
my $info = optimization(qr/^\d+foo/);
print $info->{anchored}; # 'foo'
print $info->{'anchor SBOL'}; # 1
print $info->{minlen}; # minimum match length
What you get back#
A hashref, or undef if the argument is not a compiled pattern
or its engine is unknown. Keys include minlen, minlenret,
gofs, anchored, anchored utf8, anchored min offset,
anchored max offset, anchored end shift, floating,
floating utf8, floating min offset, floating max offset,
floating end shift, checking ("anchored", "floating",
or "none"), the booleans noscan, isall, anchor SBOL,
anchor MBOL, anchor GPOS, skip, implicit, and
stclass.
Edge cases#
Argument is not a
qr//— returnsundef.Pattern has no extracted substrings — the substring-related keys are
undefor0andcheckingis"none".
Differences from upstream#
stclassis alwaysundef. Upstream returns a textual rendering of the start class produced bymy_regprop, which is compiled only withPERL_EXT_RE_DEBUGand is not available in this build.