I tried to use this regex: my @ttt = $ttt =~ /(\$sub\d+->\(.*\))?.*?\1/gs;

But it is not correct. The main problem is that I want to extract THE WHOLE function call expression: $sub111->(...) (it should contain BOTH opening AND closing parentheses). See extracted examples above.