in reply to Re: keys on scalar warnings and lack thereof
in thread keys on scalar warnings and lack thereof

I didn't include %{$_[0]} because it's obviously ok:
perl -MDevel::Peek -e 'Dump(%{$_[0]})' SV = PVHV(0x157010280) at 0x15700ae40 REFCNT = 1 FLAGS = (SHAREKEYS) ARRAY = 0x0 KEYS = 0 FILL = 0 MAX = 7 But what is this: perl -MDevel::Peek -e 'Dump(%$_[0])' SV = NULL(0x0) at 0x100939eb8 REFCNT = 2147483641 FLAGS = (READONLY,PROTECT) and this: perl -MDevel::Peek -e 'Dump(%$^[0])' SV = IV(0x159825cf0) at 0x159825d00 REFCNT = 1 FLAGS = (PADTMP,IOK,pIOK) IV = 5796572328 perl -MDevel::Peek -e 'Dump(%{$^[0]})' Number found where operator expected (Missing operator before "0"?)
And all the other weird looking results?

Replies are listed 'Best First'.
Re^3: keys on scalar warnings and lack thereof
by LanX (Saint) on May 14, 2026 at 18:35 UTC

    What exactly do you expect from broken code?

    $ perl -E' $_[0] = {}; say keys %$_[0]' Experimental keys on scalar is now forbidden at -e line 1. Type of arg 1 to keys must be hash or array (not index/value array sli +ce) at -e line 1, at EOF Execution of -e aborted due to compilation errors.

    Please note the not index/value array slice , because that's what's fed into keys.

    Try keys %{$_}[0] and compare the error messages...

    Update

    Admittedly, I've never used this before: Index/Value-Array-Slices

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery