# foo(text, regexp, replacement) # print text with replacements sub foo { my $text; ($text = $_[0]) =~ s/$_[1]/$_[2]/; print $text; } foo("This is test 1\n", "test (.*)", "fish $1");