perl -pi.bak -e '/from stuff/ or next; ($d)=$ARGV=~/(\d\d)\.txt$/; \ s/from stuff/$& where thing = "$d"/' *.txt