Yes, absolutely right - double quotes. Replacing with single quotes makes '\W' work like a charm. Thanks.

But, just to be finicky and difficult, '\W\s' is still converting spaces to &#32.

UPDATE:

Ya, of course it was. This is the list of UNSAFE characters to be encoded. So if I include '\W\s', that specificlaly tells it to encode spaces. What I want is '^\w\s' - anything that's not a word char or a space. Works perfect now.

UPDATE 2

OK, now this is very cool. With this formulation, I can create a very well defined list of what is and is not to be encoded. For example (what I'm using):

$encoded = encode_entities($input'^\w\s.\-');
encodes everything that is NOT a word char, or a space, or a period, or a dash (backslash needed to escape 'cause the dash is part of the module's syntax)

In reply to Re^4: HTML::Entities - encode all non-alphanumeric and foreign chars? by punch_card_don
in thread HTML::Entities - encode all non-alphanumeric and foreign chars? by punch_card_don

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.