#!/usr/bin/perl -w # read modified output from "spell", make changes. # usage: fixspell doc changes # doc = original document # changes = tab-separated fields: first field = error, second = correction use File::Slurp; use strict; my $err = "usage: $0 doc changes\n"; my $doc = shift(@ARGV) or die "$err"; my $changes = shift(@ARGV) or die "$err"; my $max = 0; my (@from, @to); open(CH, "< $changes") || die; while () { chomp; ($a, $b) = split(/\t/); push(@from, $a); push(@to, $b); $max++; } close(CH); $_ = read_file("$doc"); my $k = 0; while ($k < $max) { s/$from[$k]/$to[$k]/g; $k++; } print; exit(0);