Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Dear monks, I am wondering how to define an exception from a character class in a regexp. Here is an example:

1. simple removal of punctuation:

my $text = q{"This is dad's car." "OK", he said.}; $text =~ s{\p{Punct}}{}xmsg;
2. I want to remove punctuation except the apostrophe. I don't want to make just:
$text =~ s{(?<!dad)\p{Punct}}{}xmsg;

because I need to apply the regexp in a general way. This is maybe a trivial problem and I have overlooked something, but how can I do it? (With a conditional expression (?(condition)yes-pattern|no-pattern)?)

Thank you.

In reply to Exception from a character class by pirkil

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?
    [Corion]: usemodperl: Naah, if you scroll back, you'll find several approaches that still work. Maybe a prewrapped solution like CPAN::Mini is what you want. Or maybe App::FatPacker. But you don't seem to want to listen. That's OK.
    [Corion]: There, there. It'll all be better.
    [marto]: usemodperl "so to answer my question, no http at cpan," doesn't tie up with what you said "I can find cpan mirrors on http"
    [usemodperl]: yea but http only has tar.gz, i wanna download modules with core perl, but http seems to make it impossible, that's my only question, how to find http mirrors like meta, or how to do it with core perl, but options now seem totally broken (on purpose :-(
    marto wanders off
    [usemodperl]: Corion it's really not misguided, it's the only way, to do something... wonderful IMHO
    [Corion]: usemodperl: Why don't you set up your own (http-only) CPAN mirror? Or just fatpack your scripts? I wonder what problem you're trying to solve here.
    [usemodperl]: don't worry about that, it's really cool, i promise!
    [Corion]: usemodperl: Well, if the world changes and makes your "wonderful" approach not work anymore, you can either change your approach, or change the world. You seem to want to change others instead.
    [usemodperl]: no dude i'm just asking how to access meta via http and you are getting defensive for some reason (did you turn off http at meta? :-)

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (8)
    As of 2018-06-24 16:29 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?



      Results (126 votes). Check out past polls.

      Notices?