at the same time print $#arr_ref is printing -1.
Of course. You never put anything in @arr_ref. Start by using use strict; use warnings;.
so@array -> @$ref or @{$ref}
$#array -> $#$ref or $#{$ref}
In reply to Re: Print last element using perl reference
by ikegami
in thread Print last element using perl reference
by gobisankar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |