Perl | unshift() Function Last Updated : 06 Mar, 2023 Comments Improve Suggest changes Like Article Like Report unshift() function in Perl places the given list of elements at the beginning of an array. Thereby shifting all the values in the array by right. Multiple values can be unshift using this operation. This function returns the number of new elements in an array. Syntax: unshift(Array, List)Returns: Number of new elements in Array Example 1: Perl #!/usr/bin/perl # Initializing the array @x = ('Geeks', 'for', 'Geeks'); # Print the Initial array print "Original array: @x \n"; # Prints the number of elements # returned by unshift print "No of elements returned by unshift: ", unshift(@x, 'Welcome', 'to'); # Array after unshift operation print "\nUpdated array: @x"; Output: Original array: Geeks for Geeks No of elements returned by unshift: 5 Updated array: Welcome to Geeks for Geeks Example 2: Perl #!/usr/bin/perl # Initializing the array @x = (10, 20, 30, 40, 50); # Print the Initial array print "Original array: @x \n"; # Prints the number of elements # returned by unshift print "No of elements returned by unshift: ", unshift(@x, 70, 80, 'Geeks'); # Array after unshift operation print "\nUpdated array: @x"; Output: Original array: 10 20 30 40 50 No of elements returned by unshift: 8 Updated array: 70 80 Geeks 10 20 30 40 50 Example - 3 : Unshifting two lists. Perl #!/usr/bin/perl my @arr_1 = ("is","the","best"); my @arr_2 = ("Geeks","for","Geeks"); unshift @arr_1, @arr_2; print("@arr_1"); Output - Comment More infoAdvertise with us Next Article Perl | unshift() Function C Code_Mech Follow Improve Article Tags : Perl Perl-function Perl-Array-Functions Similar Reads Perl | shift() Function shift() function in Perl returns the first value in an array, removing it and shifting the elements of the array list to the left by one. Shift operation removes the value like pop but is taken from the start of the array instead of the end as in pop. This function returns undef if the array is empt 2 min read Perl | sqrt() Function Many times it happens that while solving mathematical expressions we require to calculate the square root of a number. To solve this issue, like other programming language Perl provides us with a built-in function sqrt() which can be used to calculate the square root of a number. Syntax: sqrt value 1 min read Perl | tell() Function tell() function in Perl is used to get the position of the read pointer in a File with the use of its FileHandle. If no FileHandle is passed then it returns the position within the most recent accessed file. Syntax: tell(FileHandle) Parameter: FileHandle: Filehandle of the file to be accessed. Retur 1 min read Perl | reverse() Function reverse() function in Perl when used in a list context, changes the order of the elements in the List and returns the List in reverse order. While in a scalar context, returns a concatenated string of the values of the List, with each character of the string in the opposite order. Syntax: reverse Li 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 | 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 | ord() Function The ord() function is an inbuilt function in Perl that returns the ASCII value of the first character of a string. This function takes a character string as a parameter and returns the ASCII value of the first character of this string. Syntax: ord string Parameter: This function accepts a single par 1 min read Perl | chop() Function The chop() function in Perl is used to remove the last character from the input string. Syntax: chop(String) Parameters: String : It is the input string whose last characters are removed. Returns: the last removed character. Example 1: Perl #!/usr/bin/perl # Initialising a string $string = "GfG 1 min read Perl | atan2() Function This function is used to calculate arctangent of Y/X in the range -PI to PI. Syntax: atan2(Y, X) Parameters: Y and X which are axis values Returns: Function returns arctangent of Y/X in the range -PI to PI. Example1: Perl #!/usr/bin/perl # Assigning values to X and y $Y = 45; $X = 70; # Calling atan 1 min read Perl | List Functions A list in Perl is a collection of scalar values. We can access the elements of a list using indexes. Index starts with 0 (0th index refers to the first element of the list). We use parenthesis and comma operators to construct a list. In Perl, scalar variables start with a $ symbol whereas list varia 4 min read Like