>>272
おまえのできてないだろwww

#!/usr/bin/perl
use strict;

my $pattern=<STDIN>; chomp $pattern;
my $replace=<STDIN>; chomp $replace;

while (! eof STDIN) {
 my $string =<STDIN>; chomp $string;

 if (my (@matches) = ($string =~ /$pattern/)) {
  my $rep = $replace;
  $rep =~ s/\$(\d+)/$matches[($1 -1)];/eg;
  $string =~ s/$pattern/$rep/eg;
 }
 print $string,"\n";
}