Dear AnomalousMonk,
Yes it worked, and I am so happy. Thank you for your big help. I cant believe that it is solved finally. It is more than one week which I try different solutions and you did it.
Comment on Re^5: sed command with variable in perl
Actually, the monk you have to thank is poj, for it is the code in his or her reply that seems to have done the trick. But if I have been of any help at all, I'm quite satisfied.