search pattern and replace x-y characters in nth line after every match

Hi,

I am looking for any script which can do the following.
have to read a pattern from fileA and copy it to fileB.

fileA:
...
...
Header
...
...
..p1
...
...

fileB:
....
....
Header
...
...
..p2
....
...

The position of "p1" is fixed relative to "Header"
say x th charecter in nth line after Header.
"p1" size is also fixed 5 chars if it helps.

p2 is location and size are same as p1
i have to read "p1" from fileA and replace "p2" in fileB with "p1"

How can we do this ??

Thanks in advance.

This will work for a line, maybe more details will help me...

replace.sh:

#!/usr/bin/awk -f
FNR==1 { fnum++ }
/^HEADER$/ {h=1;l=0}
h {l++}
l==3 && fnum==1 { p1=$0; next }
l==3 && fnum==2 { print p1; next }
fnum==2 { print $0 }
[mute@geek ~/test]$ cat fileA
HEADER
some kinda of data aAAaaa
this is the new data aaAAAA
more data etc aaaa

[mute@geek ~/test]$ cat fileB
HEADER
some kinda of data in BBBB
this is the old data bbBBBb
more data etc bBBbBB

[mute@geek ~/test]$ ./replace.sh fileA fileB
HEADER
some kinda of data in BBBB
this is the new data aaAAAA
more data etc bBBbBB

Thanks scott for your quick reply.
In my case p1 starts at char 5 in line 4 after HEADER. p1 is 7 charecter long.

And each of the fileA and fileB will have same number of such occurances.
I have to copy from fileA to fileB in the same order.

This is what I came up with.

#!/usr/bin/awk -f
FNR==1 { ++fnum; c = 0; }
# keep track of line# after header
h {l++}
/^HEADER$/ { h = 1; l = 0; }
# store p1
l==4 && fnum==1 { p1[c++]=substr($0,5,7); next }
# replace p2 with p1
l==4 && fnum==2 { print substr($0,1,4) p1[c++] substr($0,12); next }
# print non-matching fileB files as-is
fnum==2 { print $0 }