$count = 10;
####
$copy = $count;
##
##
$ref = \$count; # initialise $ref's value to be a reference to $count
##
##
print "ref $ref\n";
ref SCALAR(0x000003e8)
##
##
print "ref value $$ref\n";
ref value 10
##
##
@array = (10, 20, 30);
##
##
@copy = @array;
##
##
$ref = \@array;
##
##
print "ref $ref\n";
ref ARRAY(0x000003e8)
##
##
print $ref->[1];
20
##
##
print $$ref[1];
20
##
##
%hash = (a => 1, b => 2);
##
##
$ref = \%hash;
##
##
print "ref $ref";
HASH(000003e8)
print $ref->{b};
2
print $$ref{b};
2
##
##
$array[1] = @another; # nope - number of entries in @another is assigned to $array[1]
##
##
$array[1] = \@another;
print $array[1]->[0]; # the first entry in the referenced array
##
##
sub func {
my (@arr) = @_;
if (@arr[1] eq 'command') {
...
}
func(@ten_million);
##
##
sub func {
my ($aref) =@_;
if ($aref->[1] eq 'command') {
...
}
func(\@ten_million);
##
##
$ref = \@array;
print "ref $ref\n";
ARRAY(000003e8)
$ref++;
print "ref $ref\n";
1001