in reply to Storing pattern matches
The qr// operator, described in perlop is used to create regexp objects that can be used later on. This is essentially compiling and storing the regular expression. The regexp object can either be interpolated into a larger expression, or used by itself. For example:
my $bobs = qr/(?:\b(?:[Bb]ob|[Rr]obert)\b)/; my $franks = qr/(?:\b[Ff]ran(?:k(?:lin)?|cis)\b)/; my $string = 'Franklin'; print "He's here!\n" if $string =~ m/$bobs|$franks/; print "Bob is too!\n" if "Bob" =~ $bobs;
Dave
|
|---|