I am having to replace the pipe character with a space in every instance it occurs in a file so that I can manipulate it using other 3rd party programs. This is my code, and it has worked in several other places where I've had to replace characters, but replacing the pipe makes it insert a space after every single character
sub fixspace{ $rem ="|"; $rep = " "; open FILE, "<$file"; open OUTP, ">c:\\joshperl\\deptemp.txt"; while (<FILE>) { s/$rem/$rep/go; print OUTP; } close FILE; close OUTP; }
my data looks like this originally
|03/17/03|2314|0x53('S')|03/17/03|03/19/03|0.00|0.00|133712.00|133712.00|123456433|431234533|412345901|82|3.00| and comes out like this
| 0 3 / 1 4 / 0 3 | 2 2 0 7 | 0 x 4 E ( ' N ' ) | 0 3 / 1 7 / 0 3 | 0 3 / 1 7 / 0 3 | 0 . 0 0 | 0 . 0 0 | 8 0 3 6 0 . 0 0 | 8 0 3 6 0 . 0 0 | 1 3 4 5 6 7 8 9 9 | 3 4 5 6 7 7 7 5 8 | 3 4 5 6 7 9 6 6 3 | 9 1 | 1 . 0 0 |

Don't worry about the values of the fields, I had to pull from different files and mess with the numbers to keep all our info locked away in a vault somewhere.

In reply to replacing pipe "|" by nadadogg

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.