Here is the fixed version:
#!/usr/bin/perl use warnings; use strict; my $a = "aRep"; my $b = "bRep"; my $c = "cRep"; my @Search = ("?a?", "?b?", "?c?"); my @Replace = ($a, $b, $c); my $string = '?a? ?b? ?c?'; print "old string: $string\n"; for (my $i = 0; $i < $#Search + 1; $i++) { $string =~ s/\Q$Search[$i]/$Replace[$i]/g; } print "new string: $string\n"
In reply to Re: Replace multiple strings in a string
by choroba
in thread Replace multiple strings in a string
by Axlex
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |