MeowChow has asked for the wisdom of the Perl Monks concerning the following question:

Why does the first one compile? And for that matter, what does it do?
  
perl -e 'keys %h = 42' # no errors perl -e 'keys (%h = 42)' # Type of arg 1 to keys must be hash (not list assignment) at -e line +1, at end of line # Execution of -e aborted due to compilation errors. perl -e '(keys %h) = 42' # Can't modify keys in list assignment at -e line 1, at EOF # Execution of -e aborted due to compilation errors.
Update: D'oh... perhaps I should RTFM next time :)
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print

Replies are listed 'Best First'.
Re: Assignment to keys()
by HyperZonk (Friar) on Jul 25, 2001 at 23:18 UTC
    The docs for keys says it best. When you use keys as an lvalue, you are changing the memory allocation for the hash.

    -HZ