Interestingly the script works fine with ActiveStates's 5.8.1 build (no warnings whatsoever), so AFAIK the problem is limited to the Linux build on the production server. Note that the latter does not merely throw the typical "wide character" warnings -- the script terminates with error (see below) even if the "no warnings" pramata is issued.

Since I am hardpressed to come up with a working minimal code, below is some pseudocode.

use LWP::UserAgent; use HTML::Parser; use Encode; # Grab a HTML document from the Net. # Extract links from HTML document (legacy encoding, in this case Big5 +). # Decode linked strings # In my original post I used from_to($linktext, big5, utf-8)'s # in-place conversion. Same error, though. $linktext = decode( 'big5-eten', $linktext, Encode::FB_HTMLCREF ); # Test linked texts against a list of strings #Loop of linked texts foreach ( @keywords ) { local $_ = decode('utf-8', $_); # Force utf-8 flag if ( $linktext =~ /$_/ ) { # Do something } } # Typically the initial iterations appear OK but the loop never comple +tes # before the Wide Character error shows up. # End of loop

I'm at a loss as to why the two 5.8.1 builds would behave differently even as 5.8.0 and 5.8.6 work. I also have no idea whether a workaround is possible.


In reply to Re^2: Encode module, wide character by Hank
in thread Encode module, wide character by Hank

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.