HI,

This is probably a very simple question, but I'm only in my first few days of perl programming. I'm an economist trying to fix some data that did not use negative signs but rather used letters to represent negative numbers. The data is organized in such a way that these values fill spaces that are five characters long, and there are many of them (thousands of columns by thousands of rows). I want a program that will replace them, but not a simple find-and-replace substitution. I rather need to tell perl to look at an individual string of five columns, and the next one. that is to say

OOOOOOOOOJ

is really the same as:

OOOOOJOOOO

I think there are other weird data entries. And I need to convert these in chunks. that is to say, I don't want every J to be -1, I rather need to give instructions to convert the rows between 955 and 959 to -0001 if it contains a J anywhere in that block. I have a dictionary that identifies tbe blocks (they are not all equally long) in Stata. I think I might be able to use it again. Does anyone have ideas as to an easy way to do this?

The force is not so much with me when it comes to perl (though I'm learning!).


In reply to Find and replace by five character string by wrml

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.