"shift could easily return an empty list and $x is still undef."
It could easily, yes. But it doesn't. And it's documented as retuning undef. To do something different may well subtly break a lot of code on CPAN.
That said, shift is one of those keywords that Perl allows you to override...
use subs 'shift'; sub shift (+) { my $arr = $_[0]; @$arr ? CORE::shift(@$arr) : (); }
In reply to Re^3: shift in list context buggy?
by tobyink
in thread shift in list context buggy?
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |