Was playing with splice and noticed that there is a difference between hardcoded ARRAY refenrences and softcoded ARRAY references. Hope this will help somebody in future!! See also : http://perlmaven.com/splice-to-slice-and-dice-arrays-in-perl. Please notice : I've changed the code from the above link.
$dwarfs = [ qw(Doc Grumpy Happy Sleepy Sneezy Dopey Bashful) ]; print "@{$dwarfs}\n"; print "@dwarfs\n"; @removed = splice @{$dwarfs},3 ,2; $removed = [ @removed ]; #1. please notice : this makes a copy first +of @removed . # changes to @{$removed} will NOT affect @removed #$removed = \@removed ; #2. please notice : this is a hard reference + . # changes to @{$removed} will affect @removed. # let's examine the above : Just uncomment one of the above lines # it's you're choise which one to use. pop @{$removed} ; print "@removed\n";
greetings Arno Teunisse
In reply to hard versus soft reference to ARRAY's by teun-arno
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |