Questions about this topic? Sign up to ask in the talk tab.
Difference between revisions of "Perl/Basics/Variables and Data Types/Helper Functions/Pop"
From NetSec
AlizaLorenzo (Talk | contribs) (Created page with "The pop() function is similar to the pop instruction in assembly and treats the array like a stack. {{code|text=<so...") |
Rochell4259 (Talk | contribs) |
||
(One intermediate revision by one other user not shown) | |||
Line 4: | Line 4: | ||
$popped = pop(@array); | $popped = pop(@array); | ||
</source>}} | </source>}} | ||
− | The same affect can be acheived with: <source lang="perl">$popped = $array[$#array--];</source> Warning | + | The same affect can be acheived with: |
+ | |||
+ | {{code|text=<source lang="perl">$popped = $array[$#array--];</source> }} | ||
+ | |||
+ | {{Warning|Executing '''pop()''' on an array will '''delete''' the highest order array element.}} |
Latest revision as of 08:26, 22 October 2012
The pop() function is similar to the pop instruction in assembly and treats the array like a stack.
my @array; $array[$#array] = 1; $popped = pop(@array); |
The same affect can be acheived with:
$popped = $array[$#array--]; |
Executing pop() on an array will delete the highest order array element. |