that how perl has been identified that it has to go for Array or Hash Autovivification?
Autovivification is the creation of a variable by a dereference when the variable being dereferenced is undefined.
Perl knows what to create based on the kind of deference used.
- If you have an array element dereference ($$r[$i], $r->[$i]), it'll create an array.
- If you have an hash element dereference ($$r{$k}, $r->{$i}), it'll create a hash.
- If you have an array dereference (@$r), it'll create an array.
- If you have an hash dereference (%$r), it'll create a hash.
- etc.