in reply to Re: Regex issues
in thread Regex issues
my @DELIMS = (qw( _ @ )); ... ... /[@DELIM]/ ...
If the default value of $" is unchanged, the array @DELIMS will be interpolated into the regex character class with an extraneous space character, which is then a valid part of the class: a bug waiting to happen. Locally set $" to the empty string or, better yet, use join to form the char class string.
>perl -wMstrict -le "my @DELIMS = (qw( _ @ )); ;; my $rx = qr{[@DELIMS]}; print $rx; ;; { local $\" = ''; $rx = qr{[@DELIMS]}; } print $rx; ;; my $cc = join '', @DELIMS; $rx = qr{[$cc]}; print $rx; " (?^:[_ @]) (?^:[_@]) (?^:[_@])
Do not multiply bugs without necessity!
|
|---|