In
Perl, the
operator for creating a
regexp. Naturally, it's "
pick your own delimiters", like all the other q's. If you pick the
single quote ' as your
delimiter, the insides obey a "single quote" context (
$'s and other
variable references
not expanded). Otherwise, it's "double quote" context, just like for the
m// operator. Watch those
@'s (and
$'s)!
Storing the result of qr// in a variable lets you compile the regexp just once (when the qr// is evaluated). This is easier than the old way of compiling an anonymous sub that does the matching for you.
You may also use the result of qr// inside another regular expression:
$digits = qr/\d+/;
$sign = qr/[+-]?/;
$float = qr/$sign $digits
(\. $digits)?
([Ee]$sign $digits)?/x;