in reply to "strict" violation on "sort" command with perl 5.10

At least one of the elements of @$refdataarr isn't an array ref (it's a 13), so @$a is failing. It couldn't be clearer, and you really only needed the one line of code -- since we can't see what's populating $refdataarr anyway.
eval { use strict; () = sort { @$a <=> @$b } ([1], [2], 13) }; warn "Your error I believe: $@";

-Paul

Replies are listed 'Best First'.
Re^2: "strict" violation on "sort" command with perl 5.10
by ikegami (Patriarch) on Apr 28, 2009 at 19:51 UTC

    Or $refdataarr holds 13 instead of an array ref.

    Either way, it usually happens when one does
    $ref = @array;
    when one needs to do
    $ref = \@array;
    or
    $ref = [ @array ];

    Contrary to what the OP said, it has nothing to do with 5.10. Something else changed too.

      From the OP:
      ${@$a}[0]
      I had to stare at that for a bit and then do a little experiment:
      >perl -wMstrict -le "my @ra = qw(a b c d); my $ar = \@ra; print ${ ra}[2]; print ${ @ra}[2]; print ${ $ar}[2]; print ${@$ar}[2]; " c c c c
      Sure enough, it works! I'm gobsmacked!

      Needless to say, I've never seen the second and fourth forms of the array access expression, the ones using the  @ sigil apparently redundantly. These forms are certainly not widely used, but are they ever used? I.e., is there any situation in which the  @ sigil must be used in this way?

      Update: Added $ that was MIA in ${@$a}[0].

        There are no reasons to use it, and one shouldn't use it.