in reply to Regex required to Replace the array specifiers in a string

You need to be more selective about what you are matching, and will have to repeat the substitution until all nested matches are removed
use strict; use warnings; my $string="TestVar(Test1->(xy))->Var2(Test2(10)(12))->Finalvar"; while ($string=~s/ # repeat while we make matches \( #beginning of a parenthesised group [^)(]+ # non parentheses charaters \) # end of group //gx) {} print "$string\n";
This will remove parenthesised groups, starting from the innermost

Edit: tidied up comments in code block

print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."