in reply to Re: Why am I getting Can't use string (<string value>) as an ARRAY ref wile "strict refs" in use
in thread Why am I getting Can't use string (<string value>) as an ARRAY ref wile "strict refs" in use

There's also multidimensional hashes:

perl -E'my %x; $x{1,2,3} = 4; print $x{1,2,3}, "\n";'

They're kinda weirdly implemented and not really used much.

  • Comment on Re^2: Why am I getting Can't use string (<string value>) as an ARRAY ref wile "strict refs" in use
  • Download Code

Replies are listed 'Best First'.
Re^3: Why am I getting Can't use string (<string value>) as an ARRAY ref wile "strict refs" in use
by afoken (Chancellor) on Mar 01, 2019 at 13:20 UTC
    There's also multidimensional hashes [...] They're kinda weirdly implemented and not really used much.

    Basically, all list elements are joined by $; (defaults to \034 = \x1C = ASCII FS) before using them as hash key. This is not multidimensional, it is just a poor emulation used mainly for awk compatibility.

    Problems:

    • The list elements must not contain the value of $; or else your data becomes garbage.
    • Of course, you should not modify $; at runtime or else your data becomes garbage again.
    • keys and each return the joined keys, not lists of key parts. There is no automatic split.
    • The syntax does not work for slices.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^3: Why am I getting Can't use string (<string value>) as an ARRAY ref wile "strict refs" in use
by Lotus1 (Vicar) on Feb 28, 2019 at 21:48 UTC

    I found a description of this at Multi dimensional array emulation. It looks like it is creating a hash key from the list, "1,2,3". This seems like it could be a good way to implement a sparse array.

    use warnings; use strict; use Data::Dumper; my %x; $x{1,2,3} = 4; print $x{1,2,3}, "\n"; print Dumper(\%x); __DATA__ 4 $VAR1 = { '1‡˜2‡˜3' => 4 };