Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
# First we'll define this pragma called Regexp::Ascii. This is where # the magic happens... # BEGIN { package Regexp::Ascii; $INC{'Regexp/Ascii.pm'} = __FILE__; use overload (); use Carp qw(croak carp); our %replace = ( '\d' => '[0-9]', '\D' => '[^0-9]', '\w' => '[A-Za-z0-9_]', '\W' => '[^A-Za-z0-9_]', ); sub import { shift; carp "Regexp::Ascii used with no parameters" unless @_; for (@_) { croak "Regexp::Ascii does not know what to do with '$_'" unless exists $replace{$_}; } my $find = join '|', map quotemeta, sort { length $b <=> length $a or $a cmp $b } @_; overload::constant 'qr' => sub { my $find = (my $re = shift) =~ s/($find)/$replace{$1}/eg; return $re; } } sub unimport { overload::remove_constant 'qr'; } }; # Here's our test case... # use strict; use warnings; use Test::More tests => 3; use constant ARABIC_INDIC_0 => "\x{0660}"; like(ARABIC_INDIC_0, qr/^\d$/, 'unicode'); { # use our pragma in this scope use Regexp::Ascii qw( \d \D ); unlike(ARABIC_INDIC_0, qr/^\d$/, 'ascii'); } like(ARABIC_INDIC_0, qr/^\d$/, 'unicode');
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

In reply to Re: Force ASCII regexp for all perls 5.8+ by tobyink
in thread Force ASCII regexp for all perls 5.8+ by vsespb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (5)
    As of 2014-07-28 23:27 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (210 votes), past polls