tkir
asked on
Perl - Replacing a record at a specific position
Hi,
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.
Goal:
Replace position 16 to 19 (len = 4), "THIS", with "XXXX"
and
Replace position 32 to 35 (len = 4), "THIS", with "YYY" << len different
Results:
--> 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)
Thank you
I need to change several
I need to modify a fixed length file, at several positions o
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.
Goal:
Replace position 16 to 19 (len = 4), "THIS", with "XXXX"
and
Replace position 32 to 35 (len = 4), "THIS", with "YYY" << len different
Results:
--> 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)
Thank you
I need to change several
I need to modify a fixed length file, at several positions o
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER