in reply to Word matching in string
my %subst; @subst{@name} = ( 1 .. @name ); $phylo =~ s/(\w+)/$subst{$1}||$1/eg; [download]
The || will break down if one of your replacement strings is '0'. Fortunately in this case it is not.