Replace character based on reference file problem asking

I got two files right now, input file (target file), reference file 1 (query file)

reference file 1 (long list of data)

KOLOPWMOPOPO
ADASDASD
ADSASDASDAD
.
.

target file (one long liner content)

ADASDASDTYUKOKOLOPWMOPOPOOPLUAADSASDASDADPOPOUYADADASDASD

desired output file content

XXXXXXXXTYUKOXXXXXXXXXXXXOPLUAXXXXXXXXXXXPOPOUYADXXXXXXXX
 

My purpose just want to replace those exactly character that shared among reference file 1 and target file with "X" word.
For speed up the process, Perl and awk language might be better since reference file 1 is long list of data.
Any advice or suggestion are appreciate :slight_smile:

Try:

perl -pe 'BEGIN{open O, "reference_file_1"; chomp(@a=<O>)} for $i (@a){$x="X" x length($i);s/$i/$x/g}' target_file > output_file