%[
#!/usr/interp/perl -w

# METHODS OF ACCESSING LAST ARRAY ELEMENT IN PERL
# By Louis Ziantz

# Description: This program is a demonstration different ways
#             to access the last element of an array.
# Procedure:   The last element of an array is accessed using
#             three different methods.
# Input:       None
# Output:      The size and last element of the an array.

@strings = ("first", "second", "last");

$size = @strings;       # returns size of array

print("There are $size elements in the \@strings array.\n");
print("The last element of the array is $strings[$size - 1].\n");
print("The last element of the array is $strings[$#strings].\n");
print("The last element of the array is $strings[-1].\n");
%]
