in reply to Re: Modifying File Contents
in thread Modifying File Contents

Another safeguard would be to specify that the substitution may happen only once per file. Assuming there is at least one appearance of a version string in the file, and most likely, it's near the very top of the file, that should work and protect you reasonably well.

I'm thinking that the easiest way to achieve that is to simply slurp the whole file, and process it with a single s///. Source files are usually short enough to not pose any problems. According to perlrun you can use the -0777 switch to slurp the whole file (that's a zero, not a capital O, BTW. I always make that mistake.)