@foostuffs = split /(?:tar)?bar/, $string; #### for (@foostuffs) { s/^foo// }