in reply to split every other value
my $s = join',', 1..10; my( @odds, @evens ); m[([^,]+),([^,]+)] and push @odds, $1 and push @evens, $2 for split /([^,]+,[^,]+)(?:,|$)/, $s; print "@odds\n@evens";; 1 3 5 7 9 2 4 6 8 10
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: split every other value
by Aristotle (Chancellor) on Aug 07, 2004 at 06:18 UTC | |
by BrowserUk (Patriarch) on Aug 07, 2004 at 10:28 UTC |