Just for grins I whipped up the following code:
use Data::Dumper; use strict; my @foo=qw / a b c d e f / ; printf "Before:\n"; print Dumper(\@foo); $#foo--; printf "After:\n"; print Dumper(\@foo);
When run it produced:
The key here is the decrement of $#foo which reduces the maximum index value for the array @foo. IIRC the element you are disassocating will be reaped in memory eventually.Before: $VAR1 = [ 'a', 'b', 'c', 'd', 'e', 'f' ]; After: $VAR1 = [ 'a', 'b', 'c', 'd', 'e' ];
| Peter L. Berghold -- Unix Professional Peter at Berghold dot Net | |
| Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice. | |
In reply to Re: Trying to slice off all array elements but the last one
by blue_cowdawg
in thread Trying to slice off all array elements but the last one
by talexb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |