If you want to avoid scary experimental features, the "classic" way to do this is by composition:

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $rx_vowel = qr{ [aeiouAEIOU] }xms; my $rx_cons = qr{ (?! $rx_vowel) [[:alpha:]] }xms; ;; my $rx_cvc = qr{ \b $rx_cons $rx_vowel $rx_cons \b }xms; ;; my $s = 'when did the cop get his cap and tape and run out too?'; my @captures = $s =~ m{ $rx_cvc }xmsg; dd \@captures; " ["did", "cop", "get", "his", "cap", "run"]
See perlre, perlretut, and perlrequick.

Update 1: Changed example string slightly to highlight difference between "cap" and "tape" (was "cape").

Update 2: Another ancient way to do this purely with character classes may be slightly faster because it avoids a lookaround:

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $vowel = 'aeiouAEIOU'; my $rx_vowel = qr{ [\Q$vowel\E] }xms; my $rx_cons = qr{ [^[:^alpha:]\Q$vowel\E] }xms; ;; my $rx_cvc = qr{ \b $rx_cons $rx_vowel $rx_cons \b }xms; ;; my $s = 'when did the cop get his cap and tape and run out too?'; my @captures = $s =~ m{ $rx_cvc }xmsg; dd \@captures; " ["did", "cop", "get", "his", "cap", "run"]
Note, however, the tricky double-negative  [^[:^alpha:]\Q$vowel\E] in $rx_cons: "not not-an-alpha or a vowel". See "The POSIX character class syntax" in perlre.


Give a man a fish:  <%-{-{-{-<


In reply to Re: User name character classes by AnomalousMonk
in thread User name character classes by Zenzizenzizenzic

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, details, 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, summary, 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.