#! c:\perl\bin print("Enter filename to open (text only):\n\n"); $in=; chomp $in; if ($in !~ /\.txt$/i) { $in.=".txt"; } open ($in, "$in") or die("$in could not be opened:$!\n"); print("Enter string to replace \"and\" with:\n\n"); $word=; chomp $word; print("Enter filename to SAVE text file as:\n\n"); $out=; chomp $out; if ($out !~ /\.txt$/i) { $out.=".txt"; } open($out, ">$out") or die $!; print ("\n\n\n"); $count=0; while (<$in>) { s/\band\b/$word/ig; while (/\band\b/ig) { ++$count; } print($out "$_\n"); } print "there were $count instances of \"and\" in $in"; close $out; close $in;