Thursday, October 20, 2022

Shift and Unshift in perl

 

@alphabets = (a .. f);

print "Original: @alphabets \n";
shift (@alphabets);   # removing first element of the array

print "Removing first element from an array: @alphabets\n";

unshift (@alphabets, 'a');   # adding last element of the array

print "Adding first element to an array: @alphabets";

No comments:

Post a Comment