The reverse
function is used to reverse elements of an array in Perl.
reverse @arr
@arr
: This is the array that has elements we want to reverse.
A new array with elements reversed.
# create an array@gnaam = ("Apple","Amazon", "Meta");@country = ("USA", "France", "Germany");@letters = ("o", "l", "l", "e","H");print "Before reversing: \@gnaam = @gnaam\n";print "Before reversing: \@country = @country\n";print "Before reversing: \@letters = @letter\n";# reverse arrays@gnaamRev = reverse @gnaam;@countryRev = reverse @country;@letterRev = reverse @letters;# push values to the arrayprint "After Reversing: \@gnaam = @gnaamRev\n";print "Before reversing: \@country = @countryRev\n";print "Before reversing: \@letters = @letterRev\n";
reverse
function and store them into new variables.