You can also see that there no magic involved (just wantarray) if you UTSL, GLOB_NOMAGIC option notwithstanding.
The "magic" is not in detecting the context in which you are invoked, it is in returning different
scalar values when invoked with the same
argument. This is not your math teacher's concept of a function
. If you run this
use feature 'say';
say scalar(glob('*')) for (1..2);
in a directory with more than one file, you'll get the same file, twice, then the same file and a different one. There's obviously some "hidden state" beyond scalar context. I choose to call this "magic", you can choose otherwise.