Hi there,
I'm very new to perl so I hope that you can help me.
I have a list of duplicated entries in one file and what I want to do is to search another file for those entries that appear in the first file and then rename each duplicate consecutively.
File I want to change (tab delimited):
ID Entry Entry
1 0 0
2 1 0
2 0 1
3 1 1
4 0 0
4 0 0
List of duplicates:
ID
2
4
Desired output:
ID Entry Entry
1 0 0
2.1 1 0
2.2 0 1
3 1 1
4.1 0 0
4.2 0 0
So what I thought of doing is reading both files into arrays:
$bimfile="";
$n="A";
open(BIM,"$bimfile");
my @bim=split(/\s+/,BIM);
open(DUPLICATES,"<FILENAME>");
my(@duplicates)=chomp(DUPLICATES);
foreach $duplicate (@duplicates){
if
I'm not sure what to put in as the if statement. I think maybe if entries from the @duplicates array match the entries in the @bim array then rename .1 and then .2 consecutively else just print the line.
It is important that I keep the order of the bim file and print out each line as it is?
Is this the best way of going about this or is there an easier way?
Thanks!