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:
@array = ( 10, 20, 30 );
print "Original Array: @array \n" ;
push ( @array , (35, 40, 55));
print "Updated Array: @array \n" ;
|
Output:
Original Array: 10 20 30
Updated Array: 10 20 30 35 40 55
Example 2:
@array = ( 10, A, 30 );
print "Original Array: @array \n" ;
push ( @array , (F, G, H));
print "Updated Array: @array \n" ;
|
Output:
Original Array: 10 A 30
Updated Array: 10 A 30 F G H
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
25 Jun, 2019
Like Article
Save Article