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("*");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.