Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
---------------------Modification of a read-only value attempted at a.pl line 8.
--------------------------#!/usr/bin/perl -w $x[1][1]=11; $x[1][2]=12; $x[1][3]=13; $x[2][1]=21; $x[2][2]=22; $x[2][3]=23; @sorted = sort {$b->[2]cmp $a->[2] } @x;
Debugging revealed that I can access $b->[2] ok but whenever I attempt to dereference the $a variable it dies as above. The same thing happens if I use the $$a[2] syntax instead of $a->{2]. Any perls of wisdom would be much appreciated.
Edit by tye, remove PRE tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to sort multi-dimensional arrays
by Zaxo (Archbishop) on Mar 24, 2004 at 05:56 UTC | |
|
Re: how to sort multi-dimensional arrays
by kvale (Monsignor) on Mar 24, 2004 at 05:31 UTC | |
|
Re: how to sort multi-dimensional arrays
by kappa (Chaplain) on Mar 24, 2004 at 11:01 UTC | |
by flyingmoose (Priest) on Mar 24, 2004 at 22:17 UTC | |
by etj (Priest) on Jun 23, 2022 at 15:56 UTC | |
by kappa (Chaplain) on Mar 24, 2004 at 22:41 UTC | |
by flyingmoose (Priest) on Mar 25, 2004 at 14:12 UTC | |
by TilRMan (Friar) on Mar 25, 2004 at 05:50 UTC |