#! /usr/bin/perl #use strict; #use warnings; my @test=(); #() is the empty list, resets the array my $counter = ''; # empty string, may be preferrable over zero; print "\nbefore assignment:\n"; print "values in \@test are"; print @test; #should print nothing print "\n"; print "\n value of \$counter= $counter \n"; @test=(1..50); #fills the array print "\n after assignment:\n"; print "\nfirst element of array \@test is $test[0], it is stored in slot zero\n"; $counter=$#test; print "the last element if the array is stored in slot number $counter \n"; $counter=@test; #using the array in scalar context returns the size of the array print "\nthe array \@test has $counter elements after the first assignment\n"; $test[100]=99; $counter=@test; #using the array in scalar context returns the size of the array print "\nthe array \@test has $counter elements after the second assignment\n"; print @test;