no strict 'refs'; # You are using strict, yes? for (@array) { s/\$(\w+)/${$1}/eg; }