Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Force ASCII regexp for all perls 5.8+

by kcott (Abbot)
on May 16, 2013 at 02:21 UTC ( #1033756=note: print w/ replies, xml ) Need Help??


in reply to Force ASCII regexp for all perls 5.8+

G'day vsespb,

You could set up something like this just once:

my $d = qr{[0-9]}; my $w = qr{[A-Za-z0-9_]};

And then just use $w and $d instead of \w and \d. That gives you the added benefit of still having \w and \d available if you need them. Here's a minimal test:

$ perl -le ' my $w = qr{[A-Za-z0-9_]}; print q{With \x{424}:}; print 3+6 if "\x{424}" =~ /$w/; print q{With \x{42}:}; print 3+6 if "\x{42}" =~ /$w/; ' With \x{424}: With \x{42}: 9

-- Ken


Comment on Re: Force ASCII regexp for all perls 5.8+
Select or Download Code
Re^2: Force ASCII regexp for all perls 5.8+
by vsespb (Hermit) on May 16, 2013 at 07:40 UTC
    Great idea!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-08-29 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (280 votes), past polls