use strict; use warnings; while () { @_ = (); push @_, $1 while s/()//i; $_ = join '', @_, $_; print; } __DATA__ This is an anchor and these are another couple. This more anchors and more anchors .