in reply to Re: Array splice
in thread Array splice
Just to illustrate hdb's point that Perl's arrays are dynamic — and also that Perl supports negative indexing, which C doesn't like (other than a negative index of -1 for some reason, IIRC).
>perl -wMstrict -le "my @array; print 'elements in array: ', scalar @array; ;; $array[1_000_000] = 42; print 'elements in array: ', scalar @array; ;; $array[-2] = 41;; print qq{elements at end of array: @array[ -2 .. -1 ]}; " elements in array: 0 elements in array: 1000001 elements at end of array: 41 42
Update: Changed example code.
|
|---|