unshift - to insert an element to the beginning of an array
shift will remove an element from the beginning of an array. unshift will insert one or more elements to the beginning of an array.
examples/unshift.pl
use strict; use warnings; my @animals = ('wombat', 'kenguru'); print "@animals\n"; # wombat kenguru unshift @animals, 'koala'; print "@animals\n"; # koala wombat kenguru my @birds = ('penguin', 'kiwi'); print "@birds\n"; # penguin kiwi unshift @animals, @birds; print "@animals\n"; # penguin kiwi koala wombat kenguru
Published on 2021-03-19
If you have any comments or questions, feel free to post them on the source of this page in GitHub. Source on GitHub.
Comment on this post