~/perl/monks$ cat foo.txt fish $1 ~/perl/monks$ #### #!/usr/bin/perl open FOO, "; foo("This is test 1\n", qr/test (.*)/, $foo_from_file); sub foo { (my $text = $_[0]) =~ s/$_[1]/interpolate($_[2],$1)/e; print $text; } sub interpolate { my ($str,@vars) = @_; $str =~ s/\$(\d+)/$vars[$1-1]/g; $str }