in reply to split every other value
Update: just read the part about text not numbers, so this might be more appropriate...$list = '1,2,3,4,5,6,7,8'; @odds = grep $_ % 2, split(/,/, $list); @evens = grep not($_ % 2), split(/,/, $list);
$list = 'a,b,c,d,e,f,g,h'; $i=0; @pos1 = grep not($i++ % 2), split(/,/, $list); $i=0; @pos2 = grep $i++ % 2, split(/,/, $list);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: split every other value
by Aristotle (Chancellor) on Aug 07, 2004 at 00:26 UTC |