A separate code does work for me as well. But in the full fledge code its not working. The file names ">1elwA" etc etc are stored in a hash as a key. In a loop it has to retrieve the key value, tr it, and then print the output with .fasta extension. In the embedded code it is not printing the complete file name. Maybe there is some problem in storing the file in hash. Is there some other way to capture the output of the regular expression into the key of the hash other than the way used in my code in the first sub with the name of "StoreInHash"????