Dear Monks, Thanks a lot for your help. This is not a homework problem but part of a bigger project. Here is how I did it: substr($sentence, $_, 0) = '**' for @temp1; #@temp1 contains the descending character positions used for marking. @temp2=split(' ', $sentence); #indices of the elements in @temp2 that have ^\*\* will give me their word count from the start. New thing that I learned here is that substr() could also be used for assignment...:). Thank you all beloved monks!