##
$variable =~ s/
( # start capturing to $1
(?: # not capturing, just clustering
\Q$pattern\E # $pattern in a quoted way
)
+ # one or more times
) # end capturing to $1
/
....
/x;
####
$variable =~ s/((?:\Q$pattern\E)+)/$1.$1.$1/e;
print $variable;