open (PROG, ">>$0"); seek (PROG, 0, 0); #not working while () { if ($_=~/$\$data=/){s/\$_/\$data=$new_value;/} } close (PROG);