in reply to fasta file

I guess you are doing this to learn Perl, in which case BrowserUK has already given you all the advice you need to work on this script. However, if you actually want to use this script for real work then I would strongly recommend you look into BioPerl, a lrage collection of modules that help you read loads of file formats and run and analyse results from lots of external tools. There is excellent documentation for beginners here.