http://www.perlmonks.org?node_id=955552


in reply to Re^2: List::MoreUtils before, after and ... between? (1 regex)
in thread List::MoreUtils before, after and ... between?

And did you think about the edgecase of choosing a wrong delimiter which already appears in the elements? ;)

FWIW, I'm quite often in a situation where I would prefere to apply regexes on lists, so I started meditating yesterday about a module abstracting the delimiter problem away by locally redefining a special var like $; or $\ for the delimiter and $_ for flattened list.

something like

@newlist = flat { s/START$;(.*)$;END/$1/ } @list sub flat (&@) { my ($code,@list) = @_; local ( $;, $_ ) = join_reliably (@list); $code->(); return split $;, $_ }

untested.

Cheers Rolf