CARVIEW |
Select Language
HTTP/2 200
server: nginx
content-type: text/plain;charset=UTF-8
content-encoding: gzip
content-security-policy: default-src 'self'; connect-src 'self' *.google-analytics.com; img-src 'self' data: www.google-analytics.com www.googletagmanager.com; script-src 'self' 'unsafe-inline' www.google-analytics.com www.googletagmanager.com; style-src 'self'; report-uri /csp-reports
accept-ranges: bytes
age: 0
date: Tue, 29 Jul 2025 10:55:18 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210045-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753786517.311484,VS0,VE857
vary: Accept-Encoding
strict-transport-security: max-age=31557600
content-length: 496
=over
=item unshift ARRAY,LIST
X
Add one or more elements to the B of an array. This is the
opposite of a L|/shift ARRAY>.
my @animals = ("cat");
unshift(@animals, "mouse"); # ("mouse", "cat")
my @colors = ("red");
unshift(@colors, ("blue", "green")); # ("blue", "green", "red")
Returns the new number of elements in the updated array.
# Return value is the number of items in the updated array
my $color_count = unshift(@colors, ("yellow", "purple"));
say "There are $color_count colors in the updated array";
Note the LIST is prepended whole, not one element at a time, so the
prepended elements stay in the same order. Use
L|/reverse LIST> to do the reverse.
Starting with Perl 5.14, an experimental feature allowed
C to take
a scalar expression. This experiment has been deemed unsuccessful, and was
removed as of Perl 5.24.
=back