We can use the Perl push()
function to push values to the end of an array.
push(Array, values)
Array
: This is the array to which we want to push some values.
values
: This is the value(s) we want to push to the array Array
.
The value returned is the number of elements in the newly modified array.
# create an array@gnaam = ("Google","Netflix","Apple");print "Before push: \@coins = @gnaam\n";# push values to the arraypush(@gnaam, "Amazon", "Meta");print "After push: \@gnaam = @gnaam\n"
gnaam
.push()
method.push()
method to add elements to the array we created previously.