Questions about this topic? Sign up to ask in the talk tab.

Perl/Basics/Variables and Data Types/Helper Functions/Pop

From NetSec
Revision as of 03:19, 16 July 2012 by 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...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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--];
Warning: Executing pop() on an array will delete the highest order array element.