my %replacement = ( A => 'B', C => 'D', ); my $loop_line = '[A]A[C]C'; $loop_line =~ s/\[([^\]]+)\]/$replacement{$1}/g; print "$loop_line\n";
In reply to Re: Replacing multiple matches
by Roger
in thread Replacing multiple matches
by alongwor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |