perl -wl my $search = 'aaa'; my $replace = '111'; my $text = 'aaabbbccc'; $text =~ s/$search/$replace/; print ">$text<\n"; ^D >111bbbccc<