Perl Newbie: compare two files contents with same pattern

Y

YC

Hi,

If there are two directories both with the same files with same pattern as
follows:

DirX
FileA
name=abc
address=def
tel=123

FileB
name=ghi
address=jkl
tel=789

DirY
FileA
name=mno
address=def
tel=123

FileB
name=ghi
address=jkl
tel=789

If I want to seach and compare the "address" of the two files. If the
"address" is different, I want to replace address of FileB with address of
FileA. Could anyone gives a pointer.





Thanks in advance,
YC
 
S

siva chelliah

Here is an idea:
a) collect all the addresses in file a into an array.
b) now go through file b, compare addresses, if diff. replace it.

To split the fields, you could do split("=", $field)

Easy?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top