News for hackers. Stuff that matters.
Re:Data munging in Perl 6 vs. Perl 5 by elektronjunge on Wednesday December 10, 2014 @12:53PM (#8730557)
Having implicit shared state dependent on the requested type is certainly not consistent. To a reasonably experienced perl programmer one would expect the following:

    @globs = glob("*") # all matches
    $glob1 = glob("*") # the first match of "*"
    $glob2 = glob("*.c") # the first match of "*.c"
Re:Data munging in Perl 6 vs. Perl 5 by kbenson on Wednesday December 10, 2014 @02:26PM (#8731125)
I agree that's the behavior you would want for that example. That is almost the behavior you get when use use File::Glob's bsd_glob function. For some reason it instead appears to return the last alphanumerically sorted match instead of the first. I've submitted a bug about that as well as the general lack of documentation on the true behavior of the CORE::glob() function, as outlined in my other comment.
Re:Data munging in Perl 6 vs. Perl 5 by zzzcpan on Wednesday December 10, 2014 @02:36PM (#8731191)
I disagree. You would expect what it says in documentation, and it says it should iterate over the list.

If you want the first element of the list, you should say exactly that to the compiler, i.e. force list context and take the first element:

    ($file1) = glob("*");
Re:Data munging in Perl 6 vs. Perl 5 by kbenson on Wednesday December 10, 2014 @05:18PM (#8732078)
> I disagree

I assume because you misread the example given there. If you note that $glob1 and $glob2 come from what should be different lists (all files in working dir and all files ending in .c in the working dir), then $glob1 and $glob2 should contain the first item each of their respective lists. That's exactly what the documentation says should happen.

> You would expect what it says in documentation, and it says it should iterate over the list.

Unfortunately it doesn't even do what it says in the documentation consistently. I have another comment here that outlines that fairly thoroughly. The behavior is very weird and specific to glob, and is not documented accurately.

Re:Data munging in Perl 6 vs. Perl 5 by zzzcpan on Wednesday December 10, 2014 @05:35PM (#8732158)
I guess I misread the example, sorry. I thought we were talking in the context of inconsistent behavior of Perl as a language and therefore its syntax, but not in the context of an undefined behavior of glob().
Re:Data munging in Perl 6 vs. Perl 5 by kbenson on Wednesday December 10, 2014 @06:02PM (#8732259)
We are and we aren't. elektronjunge chose an example that definitely is inconsistent, but I'm not sure that it's really indicative of Perl in general. IMHO, It's a fairly specific kind o broken, where we can't really fix the behavior because of backwards compatibility, but the documentation is just plain inadequate in this case as well.
Re:Data munging in Perl 6 vs. Perl 5 by prakashk on Wednesday December 10, 2014 @01:35PM (#8730808)
It does return the values as expected. See my other reply: https://news.ycombinator.com/item?id=8730798
Re:Data munging in Perl 6 vs. Perl 5 by kbenson on Wednesday December 10, 2014 @02:15PM (#8731056)
Actually, it doesn't, and it's complicated. See my rather long-winded reply here: https://news.ycombinator.com/item?id=8730925
Re:Data munging in Perl 6 vs. Perl 5 by zzzcpan on Wednesday December 10, 2014 @01:24PM (#8730735)