in reply to Advanced replace function
You may be looking for the /g option to s///:
my $str="abc t[poop1] def [doop2] [woop3] xyz";
$str =~ s/\[.*?\]/~~/g;
abc t~~ def ~~ ~~ xyz
But that's risky, especially if you use it a larger pattern. The /.*?/ could match a "[" or a "]". That's obviously undesirable. The following pattern avoids that problem:
Once (shame on you!)
Twice (shame on me!)
More often than I'd like to be
All the time
Just when answering stupid polls
Who you callin' a fool?
I refuse to vote in this ridiculous poll
Results (520 votes). Check out past polls.