in reply to Re: split every other value
in thread split every other value
You don't need to use a substitution if you anchor the pattern using \G. And why not capture the odd elements as well?
my ( @even, @odd ); while ( $text =~ /\G ( [^,]+ ) (?: , ( [^,]+ ) )? (?: , | \z ) /gx ) +{ push @even, $1; push @odd, $2 if defined $2; }
Makeshifts last the longest.
|
|---|