undef
Produces the undefined value, or undefines an existing variable.
Operates in three modes determined by op flags:
- MOD (lvalue placeholder): Used in list assignment patterns like
my (undef, $x) = @list. Adds a sentinel tolvalue_targetssopp_aassignskips that position. - STACKED (function call
undef $x): Pops the target from the stack and undefines it. For arrays and hashes this clears the container; for hash/array element targets it sets the element toundef; for scalars it writesundefthrough the alias. - Default: If
targis set, sets the corresponding pad slot toundef. Always pushesundefonto the stack as the return value.
Synopsis
my $x = undef;
undef $x; # set $x to undef
undef @array; # clear the array
undef %hash; # clear the hash
my (undef, @rest) = @list; # skip first element in list assignment