doesn't directly address your code issues, but here's a different approach that should do what you want from a bash prompt:
for f in `cat /home/rjs/heena/edit` ; do
perl -i.bak -0777 -pe 's/CONFIDENTIAL(.*?)own\s+risk/ /s' $f
done
Update: shell-independent method:
perl -i.bak -0777 -pe 's/CONFIDENTIAL(.*?)own\s+risk/ /s' `cat /home/rjs/heena/edit`
If the 'edit' file contains a list of directories (i wasn't entirely sure from your post), then:
for d in `cat /home/rjs/heena/edit` ; do
perl -i.bak -0777 -pe 's/CONFIDENTIAL(.*?)own\s+risk/ /s' $d/*
done
See
perlrun for info on the various switches (the
-0777 causes a slurp).