|more useful options|
shift in list context buggy?by LanX (Canon)
|on Nov 09, 2013 at 13:42 UTC||Need Help??|
LanX has asked for the
wisdom of the Perl Monks concerning the following question:
in this discussion : Re^6: Using an array element as a loop iterator I was quite disappointed to find out that shift in list context can lead to an endless loop:
This will never stop:
After some meditation I consider this at least a design flaw, there is only an empty list to assign to the LHS when @a is exhausted, so the condition should be false.
($x is of course undef then, but while has to check the list assignment not the scalar!)
To make things worse my tests revealed that the "equivalent" splice doesn't have the same behavior:
according to the docs:
OK one might argue that $i means 0 here but I still can't understand if there is a good reason justifying this breach of analogy.
Can someone shed light on this?
I suppose it's too late to fix that in newer Perl versions w/o breaking compability ... (I used 5.10)
( addicted to the Perl Programming Language)