in reply to substitution in $0

This is a safer way to do it. It will keep a history of modifications, and you can "undo" it using an editor if you want:

open (ME, ">>$0"); print ME "data\n"; close(ME); __DATA__