my @split_bits = qw( : :: \s+ ); my @result = wierd_split( 'foo:bar::baz boo:foo::bar::baz', \@split_bits ); print "Got $_\n" for @result; sub wierd_split { my ( $str, $to_do, $got ) = @_; return (@$got, $str) unless @$to_do; my $next_split = shift @$to_do; print scalar @$to_do, " splitting '$str' on '$next_split'", "\n"; my ( $want, $next ) = $str =~ m/(.*?)$next_split(.*)/m; print "'$want' '$next'\n"; push @{$got}, $want; # and now for a little recursion wierd_split( $next, $to_do, $got ) if $want; } __DATA__ 2 splitting 'foo:bar::baz boo:foo::bar::baz' on ':' 'foo' 'bar::baz boo:foo::bar::baz' 1 splitting 'bar::baz boo:foo::bar::baz' on '::' 'bar' 'baz boo:foo::bar::baz' 0 splitting 'baz boo:foo::bar::baz' on '\s+' 'baz' 'boo:foo::bar::baz' Got foo Got bar Got baz Got boo:foo::bar::baz