Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Regex issues

by AnomalousMonk (Archbishop)
on Jul 13, 2013 at 13:05 UTC ( [id://1044152]=note: print w/replies, xml ) Need Help??


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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1044152]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 21:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found