
November 27th, 2012, 10:12 AM
|
 |
Contributing User
|
|
Join Date: Apr 2008
Posts: 40
Time spent in forums: 17 h 34 m 15 sec
Reputation Power: 6
|
|
|
Split every nth comma?
Hi is there a way to split a string every nth comma and kill the comma that the split is on?
for example I have a string 11111, 22222, 33333, 44444
how can I split this into an array like:
$array[0] = 11111, 22222
$array[1] = 33333, 44444
This is what I have but it doesn't work the way i want.
Code:
my ($tnr) = 11111, 22222, 33333, 44444;
@chunk = split /.{14}/, $tnr;
foreach (@chunk) {
printf "%s\n", $_;
Any help appreciated, thanks.
|