Perl Array reverse() Function - Quick Tutorial

person typing on laptop
hackNY.org/Flickr/CC BY-SA 2.0
 @REVERSED_LIST = reverse(@ARRAY); 
Perl's reverse() function is used to reverse the order of an array. It should be noted that the function returns a reversed array but does not actually reverse the array passed into the function.
 @myNames = ('Jacob', 'Michael', 'Ethan', 'Andrew');
@reversedNames = reverse(@myNames); 
Think of the @myNames array as a row of numbered boxes, going from left to right, numbered starting with a zero.
The reverse() function would copy the contents of the boxes from the @myNames array into the @reversedNames array, while reversing their order. The value of @reversedNames then becomes ('Andrew', 'Ethan', 'Michael', 'Jacob'), and @myNames remains the same.
Format
mla apa chicago
Your Citation
Brown, Kirk. "Perl Array reverse() Function - Quick Tutorial." ThoughtCo, Oct. 21, 2017, thoughtco.com/perl-array-reverse-function-quick-tutorial-2641162. Brown, Kirk. (2017, October 21). Perl Array reverse() Function - Quick Tutorial. Retrieved from https://www.thoughtco.com/perl-array-reverse-function-quick-tutorial-2641162 Brown, Kirk. "Perl Array reverse() Function - Quick Tutorial." ThoughtCo. https://www.thoughtco.com/perl-array-reverse-function-quick-tutorial-2641162 (accessed April 25, 2018).