Perl | Useful Array functions Last Updated : 04 Aug, 2021 Summarize Comments Improve Suggest changes Share 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 infoAdvertise with us Next Article Perl | push() Function A Abhinav96 Follow Improve Article Tags : Perl Perl-function Perl-Arrays Perl-Array-Functions Similar Reads Perl | Useful Hash functions A hash is a set of key-value pairs. Perl stores elements of a hash such that it searches for the values based on its keys. Perl provides various functions to perform operations on Hashes, such as to return values of the hash, to delete elements from a hash, etc. Example: Perl #!/usr/bin/perl # Initi 2 min read Perl | Useful String functions A string in Perl is a scalar variable and start with a ($) sign and it can contain alphabets, numbers, special characters. The string can consist of a single word, a group of words or a multi-line paragraph. The String is defined by the user within a single quote (â) or double quote (â). Perl provid 3 min read Perl | Useful File-handling functions Perl was originally developed for the text processing like extracting the required information from a specified text file and for converting the text file into a different form. These operations can be performed by the use of various inbuilt file functions. Example: Perl #!/usr/bin/perl # Opening a 2 min read Perl | push() Function push() function in Perl is used to push a list of values onto the end of the array. push() function is often used with pop to implement stacks. push() function doesn't depend on the type of values passed as list. These values can be alpha-numeric. Syntax: push(Array, List) Parameter: Array: in which 2 min read Perl | Useful String Operators A string in Perl is a scalar variable and start with a ($) sign and it can contain alphabets, numbers, special characters. The string can consist of a single word, a group of words or a multi-line paragraph. The String is defined by the user within a single quote (â) or double quote (â). Operators a 3 min read Perl | Array Slices 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. Arrays can store any type of data and that data can be acce 3 min read Like