in reply to Re: syntax of multidimensional arrays and hashes
in thread syntax of multidimensional arrays and hashes

Sorry that I don't understand, but I just don't.
$tsize[$tnum] = @{$threads{$thread}};
is nonsense.

Well syntactically it's correct %threads is a HoA, so @tsize is supposed to hold the sizes of these (now indexedč) arrays.

I agree that it's hard to imagine why to store the sizes statically...

Cheers Rolf

(1) Well should be noted that $tnum is initialized but never incremented... :-)

Replies are listed 'Best First'.
Re^3: syntax of multidimensional arrays and hashes
by Marshall (Canon) on Jul 18, 2009 at 05:17 UTC
    The weird part here is that $tsize[$tnum] has pretty much no useful meaning in the code. In a list context, @{$threads{$thread}} has all the values in $threads{$threads}. In a scalar context @{$threads{$thread}} is the number of things in the @{$threads{$thread}} list.

    $tsize[$tnum] = @{$threads{$thread}};
    doesn't appear to have any real meaning or usefulness.

    use @{$threads{$thread}} instead of trying to assign a scalar value to a 'C' style @tsize array.

      I'm going to use @tsize a lot later, eg: to sort all the arrays, so I wanted to access it easily in parallel with the other arrays. And Yes, you've outed me! <G> I'm really a C programmer at heart! It'll take a while before I start thinking in Perl. In any case, $tsize is unrelated to my problem of being unable to retrieve the elements of the array members of the hash.
Re^3: syntax of multidimensional arrays and hashes
by hsfrey (Beadle) on Jul 19, 2009 at 04:37 UTC
    Rolf: >should be noted that $tnum is initialized but never incremented< Yes it is - I just cut it off when copying the code to post it this time. It's there in the full code I posted previously.