Perl | push() Function Last Updated : 25 Jun, 2019 Comments Improve Suggest changes Like Article Like Report 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 list of values is to be added List: which is to be added using push function Returns: the number of elements in new array. Example 1: Perl #!/usr/bin/perl -w # Original Array @array = ( 10, 20, 30 ); # Printing Array elements print "Original Array: @array \n"; # Calling push function to # add a list of elements push(@array, (35, 40, 55)); # Printing Updated array elements print "Updated Array: @array \n"; Output: Original Array: 10 20 30 Updated Array: 10 20 30 35 40 55 Example 2: Perl #!/usr/bin/perl -w # Original Array @array = ( 10, A, 30 ); # Printing Array elements print "Original Array: @array \n"; # Calling push function to # add a list of elements push(@array, (F, G, H)); # Printing Updated array elements print "Updated Array: @array \n"; Output: Original Array: 10 A 30 Updated Array: 10 A 30 F G H Comment More infoAdvertise with us Next Article Perl | push() Function C Code_Mech Follow Improve Article Tags : Perl Perl-function 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 | each() Function This function returns a Two-element list consisting of the key and value pair for the next element of a hash when called in List context, so that you can iterate over it. Whereas it returns only the key for the next element of the hash when called in scalar context. Syntax: each MY_HASH Parameter: M 1 min read Perl | Useful Array functions 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 2 min read Perl | Implementing a Stack Stack in Perl is a linear data structure that follows the LIFO (Last In First Out) or FILO (First In Last Out) order. In simpler terms, a stack is an array in which insertion and deletion takes place at only one end called the top of the stack. Pushing is the process of insertion of elements into a 4 min read Perl | Appending to a File When a file is opened in write mode using â>â, the content of the existing file is deleted and content added using the print statement is written to the file. In this mode, the writing point will be set to the end of the file. So old content of file remains intact and anything that is written to 2 min read Perl | Writing to a File A filehandle is a variable that is used to read and write to a file. This filehandle gets associated with the file. In order to write to the file, it is opened in write mode as shown below: open (FH, â>â, âfilename.txtâ); If the file is existing then it truncates the old content of file with the 3 min read Perl | Arrays (push, pop, shift, unshift) Perl provides various inbuilt functions to add and remove the elements in an array. .string-table { font-family: arial, sans-serif; border-collapse: collapse; border: 1px solid #5fb962; width: 100%; } .string-table td, th { background-color: #c6ebd9; border: 1px solid #5fb962; text-align: left; padd 3 min read Ruby | push() function The push() function in Ruby is used to push the given element at the end of the given array and returns the array itself with the pushed elements. Syntax: push(Elements) Parameters: Elements : These are the elements which are to be added at the end of the given array. Returns: the array of pushed el 2 min read PHP | DsVector push() Function The Ds\Vector::push() function is an inbuilt function in PHP that is used to add elements to the end of the vector. Syntax: void public Ds\Vector::push( $values ) Parameters: This function accepts a single parameter $values which contains one or more than one element to be added to the vector. Retur 2 min read Node.js push() function push() is an array function from Node.js that is used to add elements to the end of an array. Syntax:array_name.push(element)Parameter: This function takes a parameter that has to be added to the array. It can take multiple elements also. Return type: The function returns the array after adding the 1 min read Like