D
Darren Dunham
I don't understand the behavior of the following...
$ touch "file"
$ perl -e 'foreach $num (0 .. 4) { print "$num .. "; print (scalar glob("file")); print " "; print (scalar glob("file")); { print " ok\n"; } }'
0 .. file file ok
1 .. ok
2 .. file file ok
3 .. ok
4 .. file file ok
I thought that if I were to get "undef" returned on the second scalar
invocation, I would have seen one "file" in each iteration, not 2
successful followed by 2 unsuccessful.
Why does the behavior change between iterations of the foreach loop
here? I've read through glob and File::Glob and I haven't seen anything
that appears to explain this.
Thanks.
$ touch "file"
$ perl -e 'foreach $num (0 .. 4) { print "$num .. "; print (scalar glob("file")); print " "; print (scalar glob("file")); { print " ok\n"; } }'
0 .. file file ok
1 .. ok
2 .. file file ok
3 .. ok
4 .. file file ok
I thought that if I were to get "undef" returned on the second scalar
invocation, I would have seen one "file" in each iteration, not 2
successful followed by 2 unsuccessful.
Why does the behavior change between iterations of the foreach loop
here? I've read through glob and File::Glob and I haven't seen anything
that appears to explain this.
Thanks.