in reply to repeating patterns 2

I wonder if it wouldn't be best to do something like this:
@foostuffs = split /(?:tar)?bar/, $string;
This should discard all the bar and tarbar. It will look for tarbar first and discard that if it finds it, and look for bar otherwise.

Then you just need to remove the foo from the items in @foostuffs:

for (@foostuffs) { s/^foo// }

Replies are listed 'Best First'.
Re: Re: repeating patterns 2
by boo_radley (Parson) on Mar 30, 2001 at 20:36 UTC
    and as is being mentioned in the chatterbox, foo may not be present within the item :
    for (@foostuffs) { s/^foo// }
    should then be
    for (@foostuffs) { s/^foo// unless (/foo/) {process data here} }
    but I don't think that was mentioned above.