Perl Array Reverse() Function: Quick Tutorial

Person typing on laptop

hackNY.org / Flickr / CC BY-SA 2.0

Perl's reverse() function is used to reverse the order of an array. The function returns a reversed array but does not reverse the array.

@REVERSED_LIST = reverse(@ARRAY);
reverse()returns @myNames = ('Jacob', 'Michael', 'Ethan', 'Andrew');
@reversedNames = reverse(@myNames);

@myNamesreverse()@myNames@reversedNames@reversedNames('Andrew', 'Ethan', 'Michael', 'Jacob')

, and @myNames remains the same.

Format
mla apa chicago
Your Citation
Brown, Kirk. "Perl Array Reverse() Function: Quick Tutorial." ThoughtCo, Aug. 27, 2020, thoughtco.com/perl-array-reverse-function-quick-tutorial-2641162. Brown, Kirk. (2020, August 27). 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 22, 2021).