Perl - Replacing a record at a specific position
Posted on 2012-09-07
Using Perl, how could you replace a record at a specific position of a fixed length file? Also, need to do multiple replacement at different positions for the same record.
For example, the file contains the following record:
--> Need to change THIS first then THIS second ...<rest of line, 700 chars total>
Note: 1st "THIS" is at positions 16-19 and 2nd "THIS" is at position 32-35.
Replace position 16 to 19 (len = 4), "THIS", with "XXXX"
Replace position 32 to 35 (len = 4), "THIS", with "YYY" << len different
--> Need to change XXXX first then YYYS second ...<rest of line, 700 chars total>
Note: The 2nd replacement replaced "THIS" with "YYYS"; 'S' was kept and the records length was not changed, contained 700 chars (same as original)
I need to change several
I need to modify a fixed length file, at several positions o