You're proving your own point about the subtlety of reference handling and the important of coding standards in Perl. Was that intentional?
say @{$ref}->[0];
This raises a deprecation warning for me. say @{$ref}[0];
This is technically correct, as the leading sigil "@" indicates you are returning an array, but since you're only returning one element in that array, this should probably be "${$ref}[0]" which returns a scalar only. say $ref->[0];
This the only form which I would consider correct or "clean".This example proves nothing about Perl's power, though. The fact that difficult and fiddly reference handling shenanigans are necessary to handle something as trivial as nested arrays and hashes shows quite the opposite.