Copyright © tutorialspoint.com

# PERL qr(expr) Function

## Syntax

qr EXPR

## Definition and Usage

This operator quotes its STRING as a regular expression. STRING is interpolated the same way as PATTERN in m/PATTERN/

## Return Value

- Returns a Perl value which may be used instead of the corresponding /STRING/ expression.

## Example

    $rex = qr/my.STRING/is;
    s/$rex/foo/;

    is is equivalent to

    s/my.STRING/foo/is;

The result may be used as a subpattern in a match:

    $re = qr/$pattern/;
    $string =~ /foo${re}bar/;	# can be interpolated in other patterns
    $string =~ $re;			# or used standalone
    $string =~ /$re/;		# or this way

Copyright © tutorialspoint.com