# NOTE: Expected to be run with the -i option if you want changes to be made $textdir='text'; $wikid_dir='.'; $lastfile=''; while (<>) { if (m/text=/) { if (open(TEXT, "<$textdir/${ARGV}.txt")) { while () { if ($lastfile && $lastfile != $ARGV) { #Finish up old file } chomp; print "text=" if ($. == 1); print "%0a" if ($. > 1); s/%/%25/g; print; } close(TEXT); } else { print STDERR "Cannot open $textdir/${ARGV}.txt\n"; print; # if you can't find the text file just bypass } } else { print; } }