#!/usr/bin/perl -w use strict; use Term::ReadLine; # for correction and command history you must have # Term::ReadLine::Gnu (from CPAN) installed my $term = new Term::ReadLine 'regexp Smode'; my $pr1 = "string: "; my $pr2 = "replace: "; my $pr3 = "with: "; my $pr4= "suffix: "; my $OUT = $term -> OUT || *STDOUT; my $output; while (1) { my $string = $term -> readline($pr1); my $replace = $term->readline($pr2); my $with = $term->readline($pr3); my $suffix = $term->readline($pr4); eval{ eval "(\$output = \$string) =~ s/\$replace/\$with/$suffix" }; print $OUT "$output\n"; }