Jun 11, 2013

Push Pop in Perl

Push/Pop      => It works at the end of the array
Push => Appends an element to end of an array
Pop  => Deletes an element from end of an array

@myNames = ('Larry', 'Curly');
push(@myNames, 'Moe');     #It adds 'Moe' at the end of the array

O/P: ('Larry', 'Curly', 'Moe')


@myNames = ('Larry', 'Curly', 'Moe');
$oneName = pop(@myNames);  #It removes 'Moe' from the end of the array

O/P: ('Larry', 'Curly')  

No comments:

Post a Comment