hi. I have a program to readline by line from a file. I want to replace certain portion of the line then write it out to a new file.

but I don't know how to replace strings that contrain certain characters embeded within them: for example:

source string 1230,5,6,12344,adblock.dll,c:\program files\document and settings\1800cursor.dll,,,,,123,1,2,2 new string: 1230,5,6,12344,adblock.dll,c:\program files\system32\afvdefdcec.exel,,,,,123,1,2,2 another example: 12,3,4,ascii sample,123,c:\ascii\121243.php,1,3,45,5 to 12,3,4,hi-ascii sample,123,c:\@#$%^.rexehp,1,3,45,5

the only thing I know it ia position based. how can i do that? my goal is to make a function that takes (sourceline, source_word,replacement) then it will do the replacement regardless all these 3 parameters contain hiascii,ascii, or dbcs.. how to archieve that. I only have a version that works with ascii and without those special characters like \ ....

please help.

GrandFather fixed formatting


In reply to string replacement question by edwardt_tril

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.