tutorial
- perl references Tutorial
- perl references
- perl function abs
- perl function accept
- perl function alarm
- perl function atan2
- perl function bind
- perl function binmode
- perl function bless
- perl function caller
- perl function chdir
- perl function chmod
- perl function chomp
- perl function chop
- perl function chown
- perl function chr
- perl function chroot
- perl function close
- perl function closedir
- perl function connect
- perl function continue
- perl function cos
- perl function crypt
- perl function dbmclose
- perl function dbmopen
- perl function defined
- perl function delete
- perl function die
- perl function do
- perl function dump
- perl function each
- perl function endgrent
- perl function endhostent
- perl function endnetent
- perl function endprotoent
- perl function endpwent
- perl function endservent
- perl function eof
- perl function eof
- perl function eval
- perl function exec
- perl function exists
- perl function exit
- perl function exp
- perl function fcntl
- perl function fileno
- perl function flock
- perl function fork
- perl function format
- perl function formline
- perl function getc
- perl function getgrent
- perl function getgrgid
- perl function getgrnam
- perl function gethostbyaddr
- perl function gethostbyname
- perl function gethostent
- perl function getlogin
- perl function getnetbyaddr
- perl function getnetbyname
- perl function getnetent
- perl function getpeername
- perl function getpgrp
- perl function getppid
- perl function getpriority
- perl function getprotobyname
- perl function getprotobynumber
- perl function getprotoent
- perl function getpwent
- perl function getpwnam
- perl function getpwuid
- perl function getservbyname
- perl function getservbyport
- perl function getservent
- perl function getsockname
- perl function getsockopt
- perl function glob
- perl function gmtime
- perl function goto
- perl function grep
- perl function hex
- perl function import
- perl function index
- perl function int
- perl function ioctl
- perl function join
- perl function keys
- perl function kill
- perl function last
- perl function lc
- perl function lcfirst
- perl function length
- perl function link
- perl function listen
- perl function local
- perl function localtime
- perl function lock
- perl function log
- perl function lstat
- perl function m
- perl function map
- perl function mkdir
- perl function msgctl
- perl function msgget
- perl function msgrcv
- perl function msgsnd
- perl function my
- perl function next
- perl function no
- perl function oct
- perl function open
- perl function opendir
- perl function ord
- perl function our
- perl function pack
- perl function package
- perl function pipe
- perl function pop
- perl function pos
- perl function print
- perl function printf
- perl function prototype
- perl function push
- perl function q
- perl function qq
- perl function qr
- perl function quotemeta
- perl function qw
- perl function qx
- perl function rand
- perl function read
- perl function readdir
- perl function readline
- perl function readlink
- perl function readpipe
- perl function recv
- perl function redo
- perl function ref
- perl function rename
- perl function require
- perl function reset
- perl function return
- perl function reverse
- perl function rewinddir
- perl function rindex
- perl function rmdir
- perl function s
- perl function scalar
- perl function seek
- perl function seekdir
- perl function select
- perl function semctl
- perl function semget
- perl function semop
- perl function send
- perl function setgrent
- perl function sethostent
- perl function setnetent
- perl function setpgrp
- perl function setpriority
- perl function setprotoent
- perl function setpwent
- perl function setservent
- perl function setsockopt
- perl function shift
- perl function shmctl
- perl function shmget
- perl function shmread
- perl function shmwrite
- perl function shutdown
- perl function sin
- perl function sleep
- perl function socket
- perl function socketpair
- perl function sort
- perl function splice
- perl function split
- perl function sprintf
- perl function sqrt
- perl function srand
- perl function stat
- perl function study
- perl function sub
- perl function substr
- perl function symlink
- perl function syscall
- perl function sysopen
- perl function sysread
- perl function sysseek
- perl function system
- perl function syswrite
- perl function tell
- perl function telldir
- perl function tie
- perl function tied
- perl function time
- perl function times
- perl function tr
- perl function truncate
- perl function uc
- perl function ucfirst
- perl function umask
- perl function undef
- perl function unlink
- perl function unpack
- perl function unshift
- perl function untie
- perl function use
- perl function utime
- perl function values
- perl function vec
- perl function wait
- perl function waitpid
- perl function wantarray
- perl function warn
- perl function write
perl function unshift
The unshift
function in Perl is used to add one or more elements to the beginning of an array. It increases the array size and moves existing elements to make room for the new elements. Here's an example:
my @fruits = ("apple", "banana", "cherry"); unshift(@fruits, "orange", "pear"); print "@fruits\n";Source:.wwwtheitroad.com
Output:
orange pear apple banana cherry
In this example, we have an array @fruits
with three elements ("apple", "banana", "cherry"). We use the unshift
function to add two more elements ("orange", "pear") to the beginning of the array. The resulting array has five elements ("orange", "pear", "apple", "banana", "cherry") which are then printed to the console using print
.