in reply to Re: Re: expanding the functionality of split
in thread expanding the functionality of split

using split can be much easier and cleaner in certain circumstances if it had this functionality

I'm not convinced that an array-based split would be so easy to work with. I think that looping a simple regex match over an array of delimiters would be easiest for the average programmer to grasp (and maintain); something like:

my @delim_seq = qw/: :: \s+ = \n/; my $string = "a:b::c d=e\n"; my @fields = (); foreach my $delim ( @delim_seq ) { $string =~ s/(.*?)$delim//; push @fields, $1; }
(Note that the final delimiter in the sequence is assumed to be the final pattern on the line -- i.e. the line terminator.)

So you have two statements inside a loop, instead of a single statement using "split(...)" -- I could live with that easily enough (whereas I'd worry about adding complexity to a basic function like "split").