Multiple choice technology programming languages

%abc = %\$def which option is correct when $def = \%any_hash ?

  1. all key value pairs are copied but in random order

  2. all key value pairs are copied in proper order

  3. all key value pairs from def may not be copied into abc

  4. syntax error

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In Perl, hashes are unordered data structures. When you copy a hash using %abc = %$def, all key-value pairs from the dereferenced hash are copied to %abc. However, hashes do not maintain any insertion order, so the copied pairs appear in random order determined by Perl's internal hash algorithm.