use warnings; use strict; use Getopt::Long qw(:config gnu_compat no_ignore_case no_debug ); # Get regexen|strings for substitution. my ($in , $out); GetOptions( 'i|in=s' => \$in , 'o|out=s' => \$out) or usage(); usage() unless defined $in && defined $out; printf "in: '%s' out: '%s'\n" , $in , $out; my $text; while () { $text .= $_; } chomp $text; printf "before:\n'%s'\n" , $text; $text =~ s/$in/$out/g; printf "after:\n'%s'\n" , $text; sub usage { die "specify strings for -in & -out options.\n"; }