slicing and dicing with references

TeeJay on 2006-12-18T17:10:39

A selection of hash slices and stuff for future reference..

my $x = [0,1,2,3,4,5]; print @$x[2,3]

my $array = [qw(aaa bbbb ccc ddd ee ffff ggg hhhhh)]; @$array[2..3] = (qw(ccc1 ddd2)); print @$array;

my @slice = @$hashref{ qw(a d) };

my $array = [[qw(aaa bbbb ccc ddd ee ffff ggg hhhhh)]]; @{$array->[0]}[2..3] = (qw(ccc1 ddd2)); print @{$array->[0]};'

my @array = @{$hash}{@keys};

See also :

http://perldoc.perl.org/perlcheat.html