Maybe I'm wrong, but I think that you are experiencing problems with the encoding of the end of line in your html file. Is your html file written in dos/Windows?, i.e has '\r\n' at the end of each line?. Are you processing it in *nix ('\n'). That would explain why you are seeing those ^M characters in vim. If that is true, Tie::File is seeing the whole file as just one line, and inserting your $line at the end of that unique line

You can see how many lines Tie::File is seeing with print $#testarray

Try one of the following (not both!):

Hope this helps

Citromatik

In reply to Re: Tie::file and html vs dos by citromatik
in thread Tie::file and html vs dos by Flubb

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.