Perl | Useful Array functions Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In Perl, array is a special type of variable. The array is used to store the list of values and each object of the list is termed as an element. Elements can either be a number, string, or any type of scalar data including another variable. Array in Perl provides various inbuilt functions to perform operations like adding and removing elements from a pre-defined array.Example: Perl #!/usr/bin/perl # Initializing the array @x = ('Java', 'C', 'C++'); # Print the Initial array print "Original array: @x \n"; # Using push() function # Pushing multiple values in the array push(@x, 'Python', 'Perl'); print("Pushing new values...\n"); # Printing the array print "Updated array: @x\n"; # Using pop() function print("\nPopping the last element...\n"); # Prints the value returned by pop print "Value returned by pop: ", pop(@x); # Prints the array after pop operation print "\nUpdated array: @x"; Output: Original array: Java C C++ Pushing new values... Updated array: Java C C++ Python Perl Popping the last element... Value returned by pop: Perl Updated array: Java C C++ Python Some useful array functions are listed below: FunctionDescriptionpush()Used to push a list of values onto the end of the arraypop()Returns the last element of Array passed to it as an argument, removing that value from the arrayshift()Returns the first value in an array, removing it and shifting the elements of the array list to the left by oneunshift()Places the given list of elements at the beginning of an array, shifting all the values to the rightsort()Used to sort a list with or without the use of method of sortingwantarray()Returns True if the currently executing subroutine expects to return a list value, and false if it is looking for a scalar value.exists()Used to check whether an element in an given array or hash exists or notgrep()Used to extract any element from the given array which evaluates the true value for the given regular expressionjoin()Combines the elements of LIST into a single string using the value of VAR to separate each element Comment More info A Abhinav96 Follow Improve Article Tags : Perl Perl-function Perl-Arrays Perl-Array-Functions Explore BasicsPerl Programming Language3 min readIntroduction to Perl9 min readPerl Installation and Environment Setup in Windows, Linux, and MacOS3 min readPerl | Basic Syntax of a Perl Program10 min readHello World Program in Perl3 min readFundamentalsPerl | Data Types3 min readPerl | Boolean Values3 min readPerl | Operators | Set - 112 min readPerl | Operators | Set - 27 min readPerl | Variables4 min readPerl | Modules3 min readPackages in Perl4 min readControl FlowPerl | Decision Making (if, if-else, Nestedâif, if-elsif ladder, unless, unless-else, unless-elsif)6 min readPerl | Loops (for, foreach, while, do...while, until, Nested loops)7 min readPerl | given-when Statement4 min readPerl | goto statement3 min readArrays & ListsPerl | Arrays6 min readPerl | Array Slices3 min readPerl | Arrays (push, pop, shift, unshift)3 min readPerl List and its Types4 min readHashPerl Hash4 min readPerl | Hash Operations8 min readPerl | Multidimensional Hashes6 min readScalarsPerl | Scalars2 min readPerl | Comparing Scalars6 min readPerl | scalar keyword2 min readStringsPerl | Quoted, Interpolated and Escaped Strings4 min readPerl | String Operators4 min readPerl | String functions (length, lc, uc, index, rindex)4 min readOOP ConceptsObject Oriented Programming (OOPs) in Perl7 min readPerl | Classes in OOP6 min readPerl | Objects in OOPs6 min readPerl | Methods in OOPs5 min readPerl | Constructors and Destructors4 min readPerl | Method Overriding in OOPs6 min readPerl | Inheritance in OOPs7 min readPerl | Polymorphism in OOPs4 min readPerl | Encapsulation in OOPs6 min readRegular ExpressionsPerl | Regular Expressions2 min readPerl | Operators in Regular Expression4 min readPerl | Regex Character Classes3 min readPerl | Quantifiers in Regular Expression4 min readFile HandlingPerl | File Handling Introduction7 min readPerl | Opening and Reading a File4 min readPerl | Writing to a File3 min readPerl | Useful File-handling functions2 min read Like