$a[0] = 'CHARLIE ROOT'; $a[1] = 'HARRY NODE'; s/[$a[~$i]]//g and print while ($i, $_) = each @a;