in reply to substition problem

Use parentheses to capture the match; this will save it into $1:
while (<>) { s/((?<!\\)\$[a-zA-Z0-9_]+)/change_name($1)/eg; }
update: Hmmm... it seems the old guy beat me to it ;-)

ar0n ]