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
String in Scalar Context and List in List Context.
Example 1: In List Context:
Example 2: In Scalar Context:
dlroW olleH skeeG roF skeeG
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.