Recursive Search and replace only when found string

Hello all ( again )
I will like to search and replace string in text file
ok I can loop throw the files like :
foreach f ( ` find . -name "*.[h|c]"`)
.. but here I like to examine the file if in contain the desired string
and so do the sed -e 's/blah/foo/g' thingy on it or there is better way ? ?
you see I don't want to rename every file and rename it back
first I will like to test its content and getting true or false

hope I made my self clear
Thanks allot

loop through all the files and use perl -p -i -e 's/blah/foo/' <filename>. This will edit the file directly and no need to copy the file and rename it