#!/usr/bin/perl -w use strict; use Term::ReadLine; my $term = new Term::ReadLine 'regexp Smode'; my $OUT = $term -> OUT || \*STDOUT; my %p; while (1){ for my $key (qw/string replace with suffix/){ $p{$key} = $term->readline("\u$key: "); exit if $p{$key} =~ /^(?:quit|exit)$/i; } eval "\$p{string} =~ s/\$p{replace}/\$p{with}/$p{suffix}"; print $OUT $@ ? "ERROR: $@\n" : "$p{string}\n\n"; }