@arr = qw(apple orange banana);
##reference to this array is ==> ref_to_arr scalar
$ref_to_arr = \@arr; ### \ indicates address of @arr
(OR)
$ref_to_arr{name
####Accessing elements (foreach)###########
foreach $ele (@$ref_to_arr) {
print " Array elements: $ele \n";
}
foreach $ele (@{ $ref_to_arr{name
print " Array elements: $ele \n";
}
####Accessing elements (for)###########
for ($i=0; $i <= $#$ref_to_arr; $i++) {
print "Array element: $ref_to_arr->[$i] \n";
}
for($i=0; $i <= $#{ $ref_to_arr{
print "Array element: $ref_to_arr{name
}
No comments:
Post a Comment