open(FILE, "/home/user/template/$filename.txt"); while () { s/(\$[a-zA-Z0-9\{\'\}_]+)/ eval ($1) /ge; $template{'content'} .= $_; } close(FILE);