wrml has asked for the wisdom of the Perl Monks concerning the following question:
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!).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Easy find and replace loop. HELP!
by Zaxo (Archbishop) on Aug 10, 2005 at 19:03 UTC | |
by Anonymous Monk on Aug 12, 2005 at 05:44 UTC | |
by Zaxo (Archbishop) on Aug 12, 2005 at 06:30 UTC | |
|
Re: Easy find and replace loop. HELP!
by Transient (Hermit) on Aug 10, 2005 at 18:24 UTC | |
by wrml (Novice) on Aug 10, 2005 at 18:33 UTC | |
by Transient (Hermit) on Aug 10, 2005 at 18:57 UTC |