Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

qr

Creates a precompiled regular expression object.

Compiles the pattern (from OpData::Pm or a runtime-interpolated string in runtime_regex_pattern) into a regex and wraps it as a blessed reference in the Regexp class. The stringified form is (?^flags:pattern), matching perl5 behaviour.

The returned object can be used directly in pattern matches, interpolated into other patterns, or stored in variables, arrays, and hashes for later use.

Synopsis

my $re = qr/pattern/flags;
$str =~ $re;             # use in match
$str =~ /${re}suffix/;   # interpolate into pattern

See Also

m//, s///, perlre, perlop