in reply to Array refs problem ...

Find out which array dereference isn't getting the array reference it expects.

Update: Your use of 0+@$FieldOrder is very suspicious.

Update: You have an array slice in the top code (note the "@" in @Array1[ LIST ]), but you have an array lookup in the bottom code (note the "$" in $Row->{ Cells }[ SCALAR ])

The equivalent of

@Array1[ LIST ] ^ |
is
@{ $array_ref }[ LIST ] ^ |

You want

@{ $Row->{ Cells } } = @{ $Row->{ Cells } }[ @$FieldOrder ];

See Dereferencing Syntax and References Quick Reference.

Replies are listed 'Best First'.
Re^2: Array refs problem ...
by Tharg (Scribe) on Jun 24, 2009 at 16:35 UTC
    Yeah I think the problem is with the way I'm dong that somehow. Adding :
    printf STDOUT ("1-->%s<--\n", $Row->{ Cells } ); printf STDOUT ("2-->%s<--\n", $FieldOrder ); printf STDOUT ("3-->%s<--\n", $Row->{ Cells }[ ( @$FieldOrder ) ] ) ;
    Gave me
    1-->ARRAY(0x2af07dc)<-- 2-->ARRAY(0x2ab07dc)<-- 3-->HASH(0x2b50058)<--
    I don't know what I would have expected for the last one (I think that's like saying $Array[1..4], which surely should be written @Array[1..4], but what do I know ...)
    Update Thanks, but tried that first, didn't work, same error.
    Update2 Oh wait, I missed that you removed the ( ) around @$FieldOrder also, I seem to be making progress now. Many thanks!

      Oh wait, I missed that you removed the ( ) around @$FieldOrder also, I seem to be making progress now. Many thanks!

      Only because they were distracting. They have absolutely no effect here.

      Just like you wouldn't use $z=($x)+($y) instead of $z=$x+$y, there's no reason to use @a[(@$b)] instead of @a[@$b].