local $_; foreach (@array) { $_ =~ s/^<%\s*(\S+?)\s*%>$/$HASH{$1} if exists $HASH{$1}/eg; }