Someone is telling me I need to escape a semicolon in a Perl regular expression literal. That is, to match a line containing a semicolon, I should use /\;/
and not /;/
.
From what I've read, the semicolon has no special meaning in a regular expression literal, so escaping it seems unnecessary. I've done some experiments and /;/
seems to work fine. With warnings turned on and the use strict;
pragma in effect, perl
doesn't complain.
Is there some reason why /\;/
is better than /;/
? Is this version-dependent?