in reply to Trying to slice off all array elements but the last one
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. | |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Trying to slice off all array elements but the last one
by dragonchild (Archbishop) on Feb 16, 2004 at 21:12 UTC | |
|
Re: Re: Trying to slice off all array elements but the last one
by Art_XIV (Hermit) on Feb 16, 2004 at 21:07 UTC | |
|
Re: Re: Trying to slice off all array elements but the last one
by CountZero (Bishop) on Feb 17, 2004 at 06:54 UTC |