in reply to Re: Empty List miracle (2)
in thread Empty List miracle (2)
Without having investigated it in more detail, I suspect that (empty_list)[0] is ()It is, in list context. In list context, such a construct is called a slice. Quoting perldata:
A slice of an empty list is still an empty list.
which turns into undef in scalar contextPerl doesn't work that way. It doesn't say, "let's evaluate EXPR in list context, then do a list-to-scalar conversion of the result". In scalar context, (empty_list)[0] is just the indexing operator. [0] is out of bounds (there's no first element), and hence, the result is undef.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Empty List miracle (2)
by ikegami (Patriarch) on Apr 29, 2010 at 15:21 UTC |