We don't bite newbies here... much | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Structures defaulting to flat lists!
@Arrays and %Hashes act per default as list not as reference which makes many useful things complicated and only some other things easy. For instance @a=(@b,@c) is not a nested structure but a flattend list, so you better choose $a=[$b,$c]. So if your working with nested structures or your passing structure in and out subroutines you need to switch to references, where you need much more typing, and you loose the "documenting" advantage of sigils. Especially if you return large arrays out of a sub as a ref to avoid copying, you cant alias them to a normal @array you need a $arr_ref. e.g. this doesn't work:
Even if you decide as a consequence to constantly work with references and you enjoy dereferencing with the arrow-operator it's annoying that you can't use the special commands for arrays and hashes directly. You need to put extra dereferencing and often additionally enclosing curlies: push @{ $hash_ref->{key_to_arr} }, "elem" instead of push $hash_ref->{key_to_arr}, "elem" Personally I think this is the biggest obstacle for beginners, a complication where many decide to look for a more intuitive language (in this aspect)!
Cheers Rolf In reply to Re: disadvantages of perl
by LanX
|
|