HI Mirod actually $tag_name=href $tag_att=attr $att_value=cde $tag_text="the string which i want to write in place of old one" Here I want to rewrite in the file --the text of the tag which is href and having attribute as "attr" value is "cde" and I want to relace this tag text with new "tag_text". there are two href tags in the file but i want to rewrite the text of only href tag which has attr="cde" in the file. if i m using the original names in the program then it works but when i m taking them as arguments then it's creating problem.