What do the shift and unshift operators do in perl?
-
Also see: https://www.lightnetics.com/post/11061
You saw in the article above that pop and push work on the right side of an array or also put at the end of an array.
shift and unshift operators work on the left side of an array or also put at the beginning of an array.
shift
This operator takes off the element or a list at the start of an array.
unshift
This operator adds an element or a list at the start of an array.
perldoc shift: https://perldoc.perl.org/functions/shift.html
perldoc unshift: https://perldoc.perl.org/functions/unshift.html
© Lightnetics 2024