AllPaoTeam has asked for the wisdom of the Perl Monks concerning the following question:
I found some code how to split an array into multiple arrays with the same length and splitting the array into even and odd array. I can't find one to split them into multiple uneven arrays. For example for the 1st array, I want the 7th word thru the 15th word in the line. For the 2nd array, I want the 16th word thru the 25th word in the line and so on. Any help would be greatly appreciated.
my $file_state = "C:\\Scripts\\TEMP_BY_STATE.csv"; #Open files to exact to each state open FILE, "<", $file_state or die $!; while ($in = <FILE>) { #Splits string into array @fields = split(/,/, $in); @data1 = $fields[6..15]; @data2 = $fields[16..25]; @data3 = $fields[26..55]; @data4 = $fields[56..60]; # and so on }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Split array into multiple uneven arrays
by choroba (Cardinal) on Sep 04, 2014 at 18:16 UTC | |
by AllPaoTeam (Sexton) on Sep 04, 2014 at 18:28 UTC | |
by AppleFritter (Vicar) on Sep 04, 2014 at 19:18 UTC |