1 #!/usr/bin/perl -w 2 # fixstyle - switch first set of strings to second set 3 # usage: $0 [-v] [files ...] 4 use strict; 5 my $verbose = (@ARGV && $ARGV[0] eq '-v' && shift); 6 if (@ARGV) { 7 $^I = ".orig"; # preserve old files 8 } else { 9 die warn "$0: Reading from stdin\n" if -t STDIN; 10 } 11 my $code = "while (<>) {\n"; 12 # read in config, build up code to eval 13 while () { 14 chomp; 15 my ($in, $out) = split /\s*=>\s*/; 16 next unless $in && $out; 17 $code .= "s{\\Q$in\\E}{$out}g"; 18 $code .= "&& printf STDERR qq($in => $out at \$ARGV line \$.\\n)" 19 if $verbose; 20 $code .= ";\n"; 21 } 22 $code .= "print;\n}\n"; 23 eval "{ $code } 1" || die; 24 __END__ 25 analysed => analyzed 26 built-in => builtin 27 chastized => chastised 28 commandline => command-line 29 de-allocate => deallocate 30 dropin => drop-in 31 hardcode => hard-code 32 meta-data => metadata 33 multicharacter => multi-character 34 multiway => multi-way 35 non-empty => nonempty 36 non-profit => nonprofit 37 non-trappable => nontrappable 38 pre-define => predefine 39 preextend => pre-extend 40 re-compiling => recompiling 41 reenter => re-enter 42 turnkey => turn-key