in reply to disadvantages of perl
@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:
my (*arr)= ret_arr_ref(); print @arr
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: disadvantages of perl
by ELISHEVA (Prior) on Jul 03, 2009 at 14:02 UTC | |
by LanX (Saint) on Jul 03, 2009 at 15:02 UTC |