Questions about this topic? Sign up to ask in the talk tab.
Difference between revisions of "Perl/Basics/Variables and Data Types/Helper Functions/Unshift"
From NetSec
AlizaLorenzo (Talk | contribs) (Created page with "* The '''unshift()''' function is like the inverse of the '''push()''' function and treats the array like a stack. In stead of pushing to the top o...") |
Chantal21I (Talk | contribs) m (moved Perl/Basics/Helper Functions/Unshift to Perl/Basics/Variables and Data Types/Helper Functions/Unshift) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
− | + | The '''unshift()''' function is like the inverse of the '''push()''' function and treats the array like a [[Assembly_Basics#The_Stack|stack]]. In stead of pushing to the top of the stack, this function operates against the bottom of the stack.{{code|text=<source lang="perl">my @array; | |
$array[0] = 1; | $array[0] = 1; | ||
unshift(@array,0); # $array[0] now contains "0" and $array[1] now contains [1]. | unshift(@array,0); # $array[0] now contains "0" and $array[1] now contains [1]. | ||
</source>}} | </source>}} |
Latest revision as of 01:19, 19 July 2012
The unshift() function is like the inverse of the push() function and treats the array like a stack. In stead of pushing to the top of the stack, this function operates against the bottom of the stack.
my @array; $array[0] = 1; unshift(@array,0); # $array[0] now contains "0" and $array[1] now contains [1]. |