It's a documented behavior of list assignments.
See perldata#List-value-constructors
Lists may be assigned to only when each element of the list is itself legal to assign to:...
An exception to this is that you may assign to undef in a list. This is useful for throwing away some of the return values of a function:
($dev, $ino, undef, undef, $uid, $gid) = stat($file);
For the rest: Perl has the symbol undef acting like a constant for the "undefined value" and a builtin function undef(EXPR) to "undefine one variable" which also returns undef to the LHS.
It might be confusing that they are equally named, but I rarely use the function anyway.
since constants are just special functions in Perl, it could be that undef and undef(EXPR) are implemented in one (magic) operator which does constant folding when called without arguments. But that's an implementation detail, located somewhere between parser and op-tree.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
In reply to Re^2: The three features of undef (renamed)
by LanX
in thread Two meanings of undef
by likbez
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |