Lists, Arrays, and Hashes
Array Append
Push appends a value to the end of an array.
Array Append
array_append.pl
use strict;
use warnings;
my @fruits = ("apple", "pear");
my $extra = ;
push @fruits, $extra;
my $joined = join(",", @fruits);
my $last = $fruits[-1];
print "extra=$extra\n";
print "joined=$joined\n";
print "last=$last\n";
use strict;
use warnings;
my @fruits = ("apple", "pear");
my $extra = ;
push @fruits, $extra;
my $joined = join(",", @fruits);
my $last = $fruits[-1];
print "extra=$extra\n";
print "joined=$joined\n";
print "last=$last\n";
use strict;
use warnings;
my @fruits = ("apple", "pear");
my $extra = ;
push @fruits, $extra;
my $joined = join(",", @fruits);
my $last = $fruits[-1];
print "extra=$extra\n";
print "joined=$joined\n";
print "last=$last\n";
push
The `push` function adds one or more values after the current last array element.