Thank you very much for your additional comments.

The scripts have not changed but the Perl version and the locale of the server. These are the variables I thought to be the reason for my problems.

The migration to a mySQL UTF8 DB is one big target but there is a bunch of things I will have to modify to achieve this.
The migration of the server is one first step.
The diffuculties I am having now help me to prepare the next steps - hopefully.

I have a couple of files with different encodings that all end up in the database
which is at the moment latin1_swedish_ci and will be some utf8 sometimes.
All migrated scripts and files worked fine so far and the first problem occured with the regex with the foreign characters in this script.

I now added:
foreach my $key (keys %$add) { $add->{$key} = encode('iso-8859-1', $add->{$key}, 1); }

which is what I would have expected to be done originally.
The outcome of the encoding is that all lines with foreign characters do not appear in the database anymore.
I get "Incorrect string value: '\xE4lter'" for example.
Without the encoding all lines are added in the database and all of them look alright.

So as far as I understand you my first assumption of the encoding of the strings in $add is wrong and I should not just insert them into a latin1_swedish_ci DB.
On the other hand encoding them produces errors during the import into a database with latin1_swedish_ci collation.
So I am having another problem I donīt yet understand yet.


In reply to Re^3: Perl encoding problem by derion
in thread Perl encoding problem by derion

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.