word substitution with incremented number

sed, substitution

Solution

perl -pe 's/DATA/ "NO" . ++$n /ge' file_in > file_out

Problem

I have a large text file where the word DATA appears more than 10000 times. I would like to know how can a make a conditional substitution, so the first time it appears in the document it is changed to NO1 and the second time to NO2 and so on, using bash. I was thinking about some complicated script using bash but there must be an easier way, I guess.

Original source