Perl (Scripting) - Regular expression delimiter

by
Jeremy Canfield |
Updated: March 09 2020
| Perl (Scripting) articles
By default, the forward slash character is used to separate fields in regular expressions in Perl.
if ($foo =~ /hello/) { print "foo contains hello"; }
Using the m character, you can use a different character to separate fields in a regular expression. In this example, m is used and # is set as the delimiter.
if ($foo =~ m#hello#) { print "foo contains hello"; }
Did you find this article helpful?
If so, consider buying me a coffee over at