Another way of doing this is to store a reference to your regex using qr(). For example,
#!/usr/bin/perl -w use strict; my $re = qr/hello/; my $string1 = "hello"; my $string2 = "good bye"; if($string1 =~ $re){ print "Match $string1\n"; } if($string2 =~ $re){ print "Match $string2\n"; }
In reply to Re: Storing Regex Patterns in Scalars
by Steve_p
in thread Storing Regex Patterns in Scalars
by iana
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |