fork download
  1. #!/usr/bin/perl
  2. %data = ('cat', 'dog', 'dog', 'cat');
  3. $x = "I have cat, cat and cat and she has dog, dog and dog.";
  4. $x =~ s/\b(dog|cat)\b/$data{$1}/eg;
  5. print $x;
Success #stdin #stdout 0s 6000KB
stdin
Standard input is empty
stdout
I have dog, dog and dog and she has cat, cat and cat.