VOOZH about

URL: https://www.geeksforgeeks.org/perl/perl-reverse-function/

⇱ Perl | reverse() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Perl | reverse() Function

Last Updated : 11 Jul, 2025
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: Output:
706050403020
6-543-21
Example 2: In Scalar Context: Output:
dlroW olleH
skeeG roF skeeG
Comment
Article Tags:

Explore