So, I am a perl newb, and am having trouble sorting a mutlidimensional array.
The data is a table, and looks like:
00000(IDR) 86480 22 41.435 40.696 40.728167 0 FRM 3
00002( P ) 35248 24 38.568 39.327 40.641 253 53 FRM 2
.
.
.
00015( B ) 9312 24 45.460 43.808 42.001 409 208 FRM 0
I read it in, line by line, parse it, and want to sort the rows in order of the first column. This is my code:
while (<FH>) { chomp $_; @line_array = split(/[()\t+\s+]/, $_); @full = map {$_ ? $_ : ()} @line_array; @{$data[$readcounter]} = @full; } @data = sort { $a->[0] <=> $b->[0] } @data;
And I get:
Modification of a read-only value attempted at...(the sort line)
What am I doing wrong? From the examples and documentation I've looked at, this is the correct way to do it, but apparently for me, its not working...
Thanks.
In reply to Read Only Error -- Sorting an Array by perlstudent89
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |