I could be totally wrong, but are you sure you want to replace ALL of them in the first loop? Like here is what I'm seeing as you're going through.
while($row = $sth->fetchrow_arrayref) { #pick up the first row as an array ref $Replacement[12]=$row->[0]; #at this point you have one item from the sql query in your #Replacement array $Kine=~s/FLF(\d\d)/$Replacement[$1]/ge; #replace all of them items in $Kine

Because you are using the /g qualifier at the end of your regular expression, it's going to hit absolutely everything in the loop, regardless of whether the SQL loads it first or not. There isn't any qualifier on the regex as to what to match, except _any_ two digits. After that point all of your FLF's have been transformed, so it's done matching. You may consider restructuring your loop or your regular expression to more closely match what you receive in $row->[0], which ever you feel more comfortable doing.

The previous example works only because they start with all of the data going into the regex, where as you do not.

Hope this helps.

    --jb

In reply to Re: Perl SQL substitution pain! by JayBonci
in thread Perl SQL substitution pain! by catcher

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.