Foundations
Arrays
Arrays store ordered values and can be read by index.
Arrays
arrays.pl
use strict;
use warnings;
my @scores = (82, 91, 76);
my $bonus = ;
my $first_score = $scores[0];
my $adjusted_score = $scores[1] + $bonus;
print "first=$first_score\n";
print "adjusted=$adjusted_score\n";
use strict;
use warnings;
my @scores = (82, 91, 76);
my $bonus = ;
my $first_score = $scores[0];
my $adjusted_score = $scores[1] + $bonus;
print "first=$first_score\n";
print "adjusted=$adjusted_score\n";
use strict;
use warnings;
my @scores = (82, 91, 76);
my $bonus = ;
my $first_score = $scores[0];
my $adjusted_score = $scores[1] + $bonus;
print "first=$first_score\n";
print "adjusted=$adjusted_score\n";
array index
Array positions start at zero, so `$scores[0]` reads the first value.