Greetings.

My script works well under perl interpreter, but dies when compiled with perl2exe (from Indigo Star). The message is: "Can't locate utf8.pm in @INC ...".

The error appears in HTML::Template module at the point where regular expression is applied to template string. The template string, passed to the module is decoded into perl's internal form with either of commands:
open(my $fh, "<:encoding($enc)", $filename);
or:
decode($content, $enc, 1);
and then the filehandle/scalarref is passed to HTML::Template->new.

When I don't decode (or when I use 2-argument open) there's no error, but output from template is displayed in wrong encoding. Input template can be in one of several encodings, so I want user to decide which encoding to use, rather then force them to use single encoding. That's why I need 3-argument open (or manual decoding).

I know that "use utf8" can't help, but I tried to include it in script and recompile the binary... It didn't help.

The only info I found about utf8 and regexps was in perlunicode: regexp engine creates 2 versions of compiled regexp - for byte and character strings.

It seems to me that perl for some reason tries to convert regexp into internal form (why it needs utf8 module then?), but fails to find it.
What's the solution? What module shuold I explicitly "use" in my script for this error to disappear? Or maybe there's deeper explanation & solution?

perl: 5.8.4


In reply to re + utf8 problem by maard

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.