in reply to Aligning sequence
You would probably benefit by taking a look at the following:
Align::NW Simple String Alignment Search for identical substrings
Update: Also, XS Mechanics, which discusses the coding of Align::NW, and has some excellent resources on the Needleman-Wunsch algorithm.
HTH,