#!/usr/bin/env perl -l use strict; use warnings; print '*** Create @x with no elements ***'; my @x; print 'Elements in @x: ', scalar @x; print '*** Use array index beyond end as RHS of assignment ***'; my $y = $x[42]; print 'Value assigned from beyond end of @x: ', defined $y ? $y : ''; print 'Elements in @x: ', scalar @x; print '*** Use array index beyond end as LHS of assignment ***'; $x[21] = 'hello'; for my $i (0, 10, 21, 32) { print "Index: $i"; print 'Value: ', defined $x[$i] ? $x[$i] : ''; } print 'Elements in @x: ', scalar @x;