Please send questions to st10@humboldt.edu .
#!/usr/bin/perl -w

#######################################################
# lect02_array1
#
# showing how you can fill any array element you want ---
# array will be set up automatically from there...
#
# modified by Sharon Tuttle from "Learning Perl",
#    by Schartz and Phoenix
#
# last modified: 8-30-04
#######################################################

# @myArray will have 7 elements after this, those with indices 0-5
# undefined:

$myArray[6] = 27;
$ct = 0;

while ($ct < 7)
{
    print "\$myArray[$ct]: ";
    if (defined($myArray[$ct]))
    {
        print "$myArray[$ct]\n";
    }
    else
    {
        print "undef\n";

    }

    $ct++;
}

# now @myArray will have 14 items

$myArray[13] = George;

print "\n";
$ct = 0;
while ($ct < 14)
{
    print "\$myArray[$ct]: ";
    if (defined($myArray[$ct]))
    {
        print "$myArray[$ct]\n";
    }
    else
    {
        print "undef\n";
    }

    $ct++;
}

# end of lect02_array1