Perl | reverse() Function Last Updated : 07 May, 2019 Comments Improve Suggest changes Like Article Like Report reverse() function in Perl when used in a list context, changes the order of the elements in the List and returns the List in reverse order. While in a scalar context, returns a concatenated string of the values of the List, with each character of the string in the opposite order. Syntax: reverse List Returns: String in Scalar Context and List in List Context. Example 1: In List Context: Perl #!/usr/bin/perl -w # Defining list of +ve Integers to the array @array1 = (20, 30, 40, 50, 60, 70); print reverse(@array1), "\n"; # Defining list of Integers to the array @array2 = (1, -2, 3, 4, -5, 6); print reverse(@array2), "\n"; Output: 706050403020 6-543-21 Example 2: In Scalar Context: Perl #!/usr/bin/perl -w # Defining string to be reversed $string = "Hello World"; print scalar reverse("$string"), "\n"; $string = "Geeks For Geeks"; print scalar reverse("$string"), "\n"; Output: dlroW olleH skeeG roF skeeG Comment More infoAdvertise with us Next Article Perl | reverse() Function C Code_Mech Follow Improve Article Tags : Perl Perl-function Perl-List-Functions Similar Reads Perl | Reverse an array Reverse an array or string in Perl. Iterative Way: Iterate over the array from 0 to mid of array. Swap the arr[i] element with arr[size-i] element. Perl #Perl code to reverse an array iteratively #declaring an array of integers @arr = (2, 3, 4, 5, 6, 7); # Store length on array in $n variable $n = $ 2 min read Perl Reverse Sort Method The article focuses on discussing how to sort an array/ list which consists of integers or strings in reverse order (descending to ascending). Prerequisite: Sorting in Perl. Syntax: reverse sort @array_name; reverse sort (@array_name); This method is a combination of the reverse and sort method of P 3 min read Perl | List Functions A list in Perl is a collection of scalar values. We can access the elements of a list using indexes. Index starts with 0 (0th index refers to the first element of the list). We use parenthesis and comma operators to construct a list. In Perl, scalar variables start with a $ symbol whereas list varia 4 min read reverse() in C++ STL In C++, the reverse() is a built-in function used to reverse the order of elements in the given range of elements. This range can be any STL container or an array. In this article, we will learn about reverse() function in C++.Letâs take a look at an example:C++#include <bits/stdc++.h> using n 3 min read R Program to reverse a number - rev() Function In this article, we will discuss how to reverse a number in R Programming Language. To reverse a number we will use in built method in R. In R Programming Language rev() function is used to return the reverse version of data objects. The data objects can be defined as Vectors, Data Frames by Columns 2 min read Like